Mercurial > code > home > repos > homeauto
view service/reasoning/oneShot @ 1416:201090b9c725
just reindent, i think
Ignore-this: 519383817f24612419191d79e14bfb5c
darcs-hash:9573fbb16b44da29f3d4f3b1c429595a13e51532
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 03 Aug 2019 17:02:16 -0700 |
parents | 1a277dba4cdc |
children | c8562ace4917 |
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, requests, time, os s, p, o = sys.argv[1:] prefixes = { '': 'http://projects.bigasterisk.com/room/', 'room' : 'http://projects.bigasterisk.com/room/', 'shuttle': 'http://bigasterisk.com/room/livingRoom/shuttlepro/', 'sensor': 'http://bigasterisk.com/homeauto/sensor/', } 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 t1 = time.time() ret = requests.post( 'http://%s/oneShot' % os.environ.get('REASONING', 'bang:9071'), headers={"content-type": "text/n3"}, data=stmt.encode('ascii')) g = float(ret.headers['x-graph-ms']) print "%.1f ms for graph update; %.1f ms other overhead" % (g, 1000 * (time.time() - t1) - g)