changeset 50:56eeda98cac5

ping reasoning Ignore-this: d3f6507918bf146bd60147c3530417e
author drewp@bigasterisk.com
date Mon, 31 Dec 2012 14:15:33 -0800
parents 0aeb8d6ea124
children d2842eedd56d
files service/tomatoWifi/tomatoWifi.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/service/tomatoWifi/tomatoWifi.py	Mon Dec 31 14:13:22 2012 -0800
+++ b/service/tomatoWifi/tomatoWifi.py	Mon Dec 31 14:15:33 2012 -0800
@@ -11,7 +11,7 @@
 Todo: this should be the one polling and writing to mongo, not entrancemusic
 """
 from __future__ import division
-import sys, cyclone.web, simplejson, traceback, time, pystache, datetime
+import sys, cyclone.web, simplejson, traceback, time, pystache, datetime, restkit
 from dateutil import tz
 from twisted.internet import reactor, task
 
@@ -36,7 +36,7 @@
 
 DEV = Namespace("http://projects.bigasterisk.com/device/")
 ROOM = Namespace("http://projects.bigasterisk.com/room/")
-
+reasoning = restkit.Resource("http://bang:9071/")
 
 class Index(PrettyErrorHandler, cyclone.web.RequestHandler):
     def get(self):
@@ -146,6 +146,13 @@
                     log.error("entrancemusic error: %r", e)
                     
             self.lastWithSignal = newWithSignal
+            if actions: # this doesn't currently include signal strength changes
+                try:
+                    reasoning.put("immediateUpdate",
+                                  # workaround for https://github.com/benoitc/restkit/issues/113
+                                  headers={'User_Agent': 'tomatoWifi'})
+                except Exception, e:
+                    log.warn(e)
             self.lastAddrs = newAddrs
             self.lastPollTime = time.time()
         except Exception, e: