TomatoDeviceScanner init optimization

This commit is contained in:
Paulus Schoutsen 2013-09-23 00:18:40 -07:00
parent 117b8454c3
commit 2d81cc65f7

View File

@ -17,8 +17,6 @@ class TomatoDeviceScanner(object):
self.config = config
self.logger = logging.getLogger(__name__)
self.lock = Lock()
self.date_updated = None
self.last_results = None
# Read known devices
if os.path.isfile(KNOWN_DEVICES_FILE):
@ -36,6 +34,9 @@ class TomatoDeviceScanner(object):
if mac not in known_devices:
writer.writerow((mac, name, 0))
self.last_results = [mac for iface, mac, rssi, tx, rx, quality, unknown_num in wldev]
self.date_updated = datetime.now()
# Create a dict with ID: NAME of the devices to track
self.devices_to_track = dict()
@ -67,6 +68,7 @@ class TomatoDeviceScanner(object):
exec(self._tomato_request("devlist"))
self.last_results = [mac for iface, mac, rssi, tx, rx, quality, unknown_num in wldev]
self.date_updated = datetime.now()
except Exception as e:
self.logger.exception("Scanning failed")