changeset 855:87111270eacf

ping reasoning Ignore-this: d3f6507918bf146bd60147c3530417e darcs-hash:20121231221533-312f9-f41349a63f70a3f01b9e6d41b00ca0c6e012a352
author drewp <drewp@bigasterisk.com>
date Mon, 31 Dec 2012 14:15:33 -0800
parents 1815d2343a3f
children 4b386fc51325
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: