Mercurial > code > home > repos > homeauto
changeset 52:875a37be1228
fix fetch calls in tomatowifi
Ignore-this: 7b9a676be589b2400a18a16b1d194343
author | drewp@bigasterisk.com |
---|---|
date | Mon, 31 Dec 2012 17:53:42 -0800 |
parents | d2842eedd56d |
children | 0141467893bf |
files | service/tomatoWifi/tomatoWifi.py service/tomatoWifi/wifi.py |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/service/tomatoWifi/tomatoWifi.py Mon Dec 31 15:01:04 2012 -0800 +++ b/service/tomatoWifi/tomatoWifi.py Mon Dec 31 17:53:42 2012 -0800 @@ -153,7 +153,8 @@ self.lastWithSignal = newWithSignal if actions: # this doesn't currently include signal strength changes fetch(reasoning + "immediateUpdate", - headers={'user-agent': 'tomatoWifi'}).addErrback(log.warn) + timeout=2, + headers={'user-agent': ['tomatoWifi']}).addErrback(log.warn) self.lastAddrs = newAddrs self.lastPollTime = time.time() except Exception, e:
--- a/service/tomatoWifi/wifi.py Mon Dec 31 15:01:04 2012 -0800 +++ b/service/tomatoWifi/wifi.py Mon Dec 31 17:53:42 2012 -0800 @@ -44,8 +44,10 @@ url = url.replace(k, v) r = Router() - r.url = url.replace('root:admin@', '') - r.headers = {'Authorization': ['Basic cm9vdDphZG1pbg==']} + http, tail = url.split('//', 1) + userPass, tail = tail.split("@", 1) + r.url = http + '//' + tail + r.headers = {'Authorization': ['Basic %s' % userPass.encode('base64').strip()]} r.name = {'tomato1' : 'bigasterisk3', 'tomato2' : 'bigasterisk4'}[name.split('/')[1]] self.routers.append(r) @@ -58,11 +60,12 @@ for router in self.routers: log.debug("GET %s", router) try: - data = yield fetch(router.url, headers=router.headers, + resp = yield fetch(router.url, headers=router.headers, timeout=2) except socket.error: log.warn("get on %s failed" % router) continue + data = resp.body for (ip, mac, iface) in jsValue(data, 'arplist'): aboutIp.setdefault(ip, {}).update(dict(