comparison service/piNode/piNode.py @ 1143:d1bc88f67969

RgbPixelsAnimation and docker build updates Ignore-this: c79e4a64bb5ad8683aa837839e79785b darcs-hash:bcc0201b2aaf3a1f1f689a6437eef8298970c58a
author drewp <drewp@bigasterisk.com>
date Sat, 03 Mar 2018 18:09:34 -0800
parents 1e43ec4a5f23
children 97f5cbcac00b
comparison
equal deleted inserted replaced
1142:eb36b30f53b9 1143:d1bc88f67969
9 9
10 logging.basicConfig(level=logging.DEBUG) 10 logging.basicConfig(level=logging.DEBUG)
11 11
12 sys.path.append("../../lib") 12 sys.path.append("../../lib")
13 from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler 13 from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler
14 from light9.rdfdb.rdflibpatch import inContext 14
15 from light9.rdfdb.patch import Patch 15 from rdfdb.rdflibpatch import inContext
16 sys.path.append('/opt/pigpio') 16 from rdfdb.patch import Patch
17
17 try: 18 try:
18 import pigpio 19 import pigpio
19 except ImportError: 20 except ImportError:
20 class pigpio(object): 21 class pigpio(object):
21 @staticmethod 22 @staticmethod
120 if log.isEnabledFor(logging.DEBUG): 121 if log.isEnabledFor(logging.DEBUG):
121 log.debug('poll times:') 122 log.debug('poll times:')
122 for u, s in sorted(pollTime.items()): 123 for u, s in sorted(pollTime.items()):
123 log.debug(" %.4f ms %s", s * 1000, u) 124 log.debug(" %.4f ms %s", s * 1000, u)
124 log.debug('total poll time: %f ms', sum(pollTime.values()) * 1000) 125 log.debug('total poll time: %f ms', sum(pollTime.values()) * 1000)
125 self._influx.exportToInflux( 126
126 set.union(*[set(v) for v in self._statementsFromInputs.values()])) 127 pollResults = map(set, self._statementsFromInputs.values())
128 if pollResults:
129 self._influx.exportToInflux(set.union(*pollResults))
127 130
128 def _sendOneshot(self, oneshot): 131 def _sendOneshot(self, oneshot):
129 body = (' '.join('%s %s %s .' % (s.n3(), p.n3(), o.n3()) 132 body = (' '.join('%s %s %s .' % (s.n3(), p.n3(), o.n3())
130 for s,p,o in oneshot)).encode('utf8') 133 for s,p,o in oneshot)).encode('utf8')
131 url = 'http://[%s]:9071/oneShot' % bang6 134 url = 'http://[%s]:9071/oneShot' % bang6
250 board = Board(config.graph, masterGraph, thisBoard) 253 board = Board(config.graph, masterGraph, thisBoard)
251 board.startPolling() 254 board.startPolling()
252 255
253 reactor.listenTCP(9059, cyclone.web.Application([ 256 reactor.listenTCP(9059, cyclone.web.Application([
254 (r"/()", cyclone.web.StaticFileHandler, { 257 (r"/()", cyclone.web.StaticFileHandler, {
255 "path": "../arduinoNode/static", "default_filename": "index.html"}), 258 "path": "static", "default_filename": "index.html"}),
256 (r'/static/(.*)', cyclone.web.StaticFileHandler, {"path": "../arduinoNode/static"}), 259 (r'/static/(.*)', cyclone.web.StaticFileHandler, {"path": "static"}),
257 (r'/boards', Boards), 260 (r'/boards', Boards),
258 (r"/graph", CycloneGraphHandler, {'masterGraph': masterGraph}), 261 (r"/graph", CycloneGraphHandler, {'masterGraph': masterGraph}),
259 (r"/graph/events", CycloneGraphEventsHandler, {'masterGraph': masterGraph}), 262 (r"/graph/events", CycloneGraphEventsHandler, {'masterGraph': masterGraph}),
260 (r'/output', OutputPage), 263 (r'/output', OutputPage),
261 (r'/dot', Dot), 264 (r'/dot', Dot),