Mercurial > code > home > repos > homeauto
view service/reasoning/oneShot @ 963:2decd45addf4
notes on pins
Ignore-this: 1fced0c832715c5fbd16011563e7120a
darcs-hash:20150120053811-312f9-cbcd7801cd4a454a3ae4a05c5534cfb0a9cbafb8
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 19 Jan 2015 21:38:11 -0800 |
parents | 3bb18b7d21df |
children | c1287ab87add |
line wrap: on
line source
#!/usr/bin/python """ send a statement to the reasoning server for one update cycle. Args are s/p/o in n3 notation, with many prefixes predefined here. """ import sys, restkit s, p, o = sys.argv[1:] prefixes = { 'room' : 'http://projects.bigasterisk.com/room/', 'shuttle': 'http://bigasterisk.com/room/livingRoom/shuttlepro/', } def expand(term): if ':' not in term or term.startswith(('<', '"', "'")): return term left, right = term.split(':', 1) if left in prefixes: return '<%s%s>' % (prefixes[left], right) return term stmt = '%s %s %s .' % (expand(s), expand(p), expand(o)) print "Sending: %s" % stmt reasoning = restkit.Resource("http://bang:9071/") reasoning.post("oneShot", headers={"content-type": "text/n3"}, payload=stmt)