Mercurial > code > home > repos > homeauto
view service/reasoning/oneShot @ 934:3bb18b7d21df
reasoning actions: generalize them a bit but then add a bunch of special cases for mpd for now
Ignore-this: 3ab80fee5836817dcd54ce6678a6089d
darcs-hash:20131009044224-312f9-b47b461e8872e4ef5c4951703ab8f13d5b848ea3
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Tue, 08 Oct 2013 21:42:24 -0700 |
parents | 6ccd930834d1 |
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)