changeset 36:0ab069867c64

rdflib and jsonlib api updates Ignore-this: feb4c3bee7704dee42f1d3a01b20f4e8
author drewp@bigasterisk.com
date Tue, 07 Aug 2012 23:24:10 -0700
parents 912a3dae5c2c
children 8e55a6a9c425
files service/onewire/onewire.py service/speechMusic/speechMusic.py service/starArduino/starArduino.py service/tomatoWifi/tomatoWifi.py service/tomatoWifi/wifi.py
diffstat 5 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/service/onewire/onewire.py	Mon Aug 06 20:18:29 2012 -0700
+++ b/service/onewire/onewire.py	Tue Aug 07 23:24:10 2012 -0700
@@ -32,7 +32,7 @@
 
 """
 from __future__ import division
-import time, logging, traceback, sys, cyclone.web, jsonlib, restkit
+import time, logging, traceback, sys, cyclone.web, restkit, json
 from twisted.internet.task import LoopingCall, deferLater
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.internet import reactor
@@ -139,8 +139,8 @@
             for tries in range(3):
                 try:
                     res = restkit.Resource(url, timeout=5)
-                    temp = jsonlib.read(res.get("temperature").body_string(), 
-                                        use_float=True)['temp']
+                    temp = json.loads(res.get("temperature").body_string(), 
+                                      )['temp']
                     log.debug("got http temp %s = %r", name, temp)
                     ret[name] = temp
                     break
--- a/service/speechMusic/speechMusic.py	Mon Aug 06 20:18:29 2012 -0700
+++ b/service/speechMusic/speechMusic.py	Tue Aug 07 23:24:10 2012 -0700
@@ -3,7 +3,7 @@
 """
 play sounds according to POST requests. cooperate with pubsubhubbub
 """
-import web, sys, jsonlib, subprocess, os, tempfile, logging
+import web, sys, json, subprocess, os, tempfile, logging
 from subprocess import check_call
 sys.path.append("/my/proj/csigen")
 from generator import tts
@@ -64,7 +64,7 @@
 
 class visitorNet(object):
     def POST(self):
-        data = jsonlib.loads(web.data())
+        data = json.loads(web.data())
         if 'name' not in data:
             data['name'] = 'unknown'
             
--- a/service/starArduino/starArduino.py	Mon Aug 06 20:18:29 2012 -0700
+++ b/service/starArduino/starArduino.py	Tue Aug 07 23:24:10 2012 -0700
@@ -4,7 +4,7 @@
 """
 from __future__ import division
 
-import sys, jsonlib
+import sys,json
 from twisted.internet import reactor, task
 from twisted.internet.task import LoopingCall
 import cyclone.web, restkit
@@ -31,7 +31,7 @@
     def get(self):
         f = self.settings.arduino.getTemperature()
         self.set_header("Content-Type", "application/json")
-        self.write(jsonlib.write({"temp" : f}))
+        self.write(json.dumps({"temp" : f}))
 
 class Brite(PrettyErrorHandler, cyclone.web.RequestHandler):
     def get(self, pos):
@@ -86,7 +86,7 @@
                                 'K':'CODE128',
                                 }[code[0]]
                     code = code[1:-1]
-                    postBarcode.post(payload=jsonlib.dumps(
+                    postBarcode.post(payload=json.dumps(
                         {'barcodeType':codeType, 'code':code}),
                                      headers={"content-type" :
                                               "application/json"})
@@ -113,7 +113,7 @@
                         break
                 else:
                     raise ValueError("timed out waiting for chars")
-            return jsonlib.loads(line)
+            return json.loads(line)
 
     sb = A(numChannels=3)
 
--- a/service/tomatoWifi/tomatoWifi.py	Mon Aug 06 20:18:29 2012 -0700
+++ b/service/tomatoWifi/tomatoWifi.py	Tue Aug 07 23:24:10 2012 -0700
@@ -25,6 +25,15 @@
 from cycloneerr import PrettyErrorHandler
 from logsetup import log
 
+import rdflib
+from rdflib import plugin
+plugin.register(
+  "sparql", rdflib.query.Processor,
+  "rdfextras.sparql.processor", "Processor")
+plugin.register(
+  "sparql", rdflib.query.Result,
+  "rdfextras.sparql.query", "SPARQLQueryResult")
+
 DEV = Namespace("http://projects.bigasterisk.com/device/")
 ROOM = Namespace("http://projects.bigasterisk.com/room/")
 
--- a/service/tomatoWifi/wifi.py	Mon Aug 06 20:18:29 2012 -0700
+++ b/service/tomatoWifi/wifi.py	Tue Aug 07 23:24:10 2012 -0700
@@ -1,5 +1,5 @@
 import re, ast, restkit, logging, socket
-from rdflib import Literal
+from rdflib import Literal, Graph
 
 log = logging.getLogger()
 
@@ -17,7 +17,6 @@
         self.knownMacAddr = jsValue(txt, 'knownMacAddr')
         tomatoUrl = jsValue(txt, 'tomatoUrl')
 
-        from rdflib.Graph import Graph
         g = Graph()
         g.parse(accessN3, format="n3")
         repl = {'/tomato1/' : None, '/tomato2/' : None}