# HG changeset patch # User drewp@bigasterisk.com # Date 1357005222 28800 # Node ID 875a37be1228f5fcff3ff3ec988241933a7eab9f # Parent d2842eedd56daacb68a845031a28f62ef10fceb1 fix fetch calls in tomatowifi Ignore-this: 7b9a676be589b2400a18a16b1d194343 diff -r d2842eedd56d -r 875a37be1228 service/tomatoWifi/tomatoWifi.py --- 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: diff -r d2842eedd56d -r 875a37be1228 service/tomatoWifi/wifi.py --- 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(