Mercurial > code > home > repos > homeauto
comparison service/tomatoWifi/tomatoWifi.py @ 383:8f5a16a55f64
various docker setups and build fixes
Ignore-this: adb559337fa1bd058818d1fc99d80ac1
author | drewp@bigasterisk.com |
---|---|
date | Fri, 28 Dec 2018 02:13:15 -0800 |
parents | 70954bd426be |
children | 10ec2744fe8a |
comparison
equal
deleted
inserted
replaced
382:61f1c529a9b7 | 383:8f5a16a55f64 |
---|---|
13 """ | 13 """ |
14 from __future__ import division | 14 from __future__ import division |
15 import sys, cyclone.web, json, traceback, time, pystache, datetime, logging | 15 import sys, cyclone.web, json, traceback, time, pystache, datetime, logging |
16 import web.utils | 16 import web.utils |
17 from cyclone.httpclient import fetch | 17 from cyclone.httpclient import fetch |
18 sys.path.append("/home/drewp/projects/photo/lib/python2.7/site-packages") | 18 |
19 from dateutil import tz | 19 from dateutil import tz |
20 from twisted.internet import reactor, task | 20 from twisted.internet import reactor, task |
21 from twisted.internet.defer import inlineCallbacks | 21 from twisted.internet.defer import inlineCallbacks |
22 import docopt | 22 import docopt |
23 from influxdb import InfluxDBClient | 23 from influxdb import InfluxDBClient |
24 from pymongo import Connection, DESCENDING | 24 from pymongo import Connection, DESCENDING |
25 from rdflib import Namespace, Literal, URIRef, ConjunctiveGraph | 25 from rdflib import Namespace, Literal, URIRef, ConjunctiveGraph |
26 sys.path.append("/my/site/magma") | 26 |
27 from stategraph import StateGraph | 27 from stategraph import StateGraph |
28 from wifi import Wifi | 28 from wifi import Wifi |
29 sys.path.append("/my/proj/homeauto/lib") | 29 |
30 from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler | 30 from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler |
31 sys.path.append("/my/proj/rdfdb") | 31 |
32 from rdfdb.patch import Patch | 32 from rdfdb.patch import Patch |
33 | 33 |
34 sys.path.append("/my/proj/homeauto/lib") | |
35 from cycloneerr import PrettyErrorHandler | 34 from cycloneerr import PrettyErrorHandler |
36 from logsetup import log | 35 from logsetup import log |
37 | 36 |
38 | 37 |
39 DEV = Namespace("http://projects.bigasterisk.com/device/") | 38 DEV = Namespace("http://projects.bigasterisk.com/device/") |
197 return actions | 196 return actions |
198 | 197 |
199 | 198 |
200 # these need to move out to their own service | 199 # these need to move out to their own service |
201 def doEntranceMusic(self, action): | 200 def doEntranceMusic(self, action): |
202 import restkit, jsonlib | 201 import restkit, json |
203 dt = self.deltaSinceLastArrive(action['name']) | 202 dt = self.deltaSinceLastArrive(action['name']) |
204 log.debug("dt=%s", dt) | 203 log.debug("dt=%s", dt) |
205 if dt > datetime.timedelta(hours=1): | 204 if dt > datetime.timedelta(hours=1): |
206 hub = restkit.Resource( | 205 hub = restkit.Resource( |
207 # PSHB not working yet; "http://bang:9030/" | 206 # PSHB not working yet; "http://bang:9030/" |
209 ) | 208 ) |
210 action = action.copy() | 209 action = action.copy() |
211 del action['created'] | 210 del action['created'] |
212 del action['_id'] | 211 del action['_id'] |
213 log.info("post to %s", hub) | 212 log.info("post to %s", hub) |
214 hub.post("visitorNet", payload=jsonlib.dumps(action)) | 213 hub.post("visitorNet", payload=json.dumps(action)) |
215 | 214 |
216 def deltaSinceLastArrive(self, name): | 215 def deltaSinceLastArrive(self, name): |
217 results = list(self.mongo.find({'name' : name}).sort('created', | 216 results = list(self.mongo.find({'name' : name}).sort('created', |
218 DESCENDING).limit(1)) | 217 DESCENDING).limit(1)) |
219 if not results: | 218 if not results: |