Mercurial > code > home > repos > homeauto
diff service/tomatoWifi/wifi.py @ 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 | f8cc3d1baa85 |
line wrap: on
line diff
--- 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(