# HG changeset patch # User drewp # Date 1344407050 25200 # Node ID ddc2cdbfde50398b79bdd3f3afc6d20e5d720b62 # Parent afc74853a1a4521b7b53acda4e14fb65f6fc04c5 rdflib and jsonlib api updates Ignore-this: feb4c3bee7704dee42f1d3a01b20f4e8 darcs-hash:20120808062410-312f9-2d5e41e2bb782e0e3946af63c6bbaf695f23fc16 diff -r afc74853a1a4 -r ddc2cdbfde50 service/onewire/onewire.py --- 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 diff -r afc74853a1a4 -r ddc2cdbfde50 service/speechMusic/speechMusic.py --- 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' diff -r afc74853a1a4 -r ddc2cdbfde50 service/starArduino/starArduino.py --- 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) diff -r afc74853a1a4 -r ddc2cdbfde50 service/tomatoWifi/tomatoWifi.py --- 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/") diff -r afc74853a1a4 -r ddc2cdbfde50 service/tomatoWifi/wifi.py --- 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}