summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemigiusz Marcinkiewicz <remigiusz@marcinkiewicz.me>2018-01-04 20:13:25 +0100
committerPiotr Dobrowolski <admin@tastycode.pl>2018-01-26 20:00:59 +0100
commit3143038458d97582c9ce3934e6d95ee9a0587f62 (patch)
tree582b2f5dd130af6b394b04bee78deb2670f903bf
parent145d13c2a7b331af6eaa9618aa1e49c7c432dfbb (diff)
downloadcheckinator-3143038458d97582c9ce3934e6d95ee9a0587f62.tar.gz
checkinator-3143038458d97582c9ce3934e6d95ee9a0587f62.tar.bz2
checkinator-3143038458d97582c9ce3934e6d95ee9a0587f62.zip
Add generic support for special device types in configuration and now_at()
-rw-r--r--at.cfg.dist5
-rw-r--r--at.py24
2 files changed, 16 insertions, 13 deletions
diff --git a/at.cfg.dist b/at.cfg.dist
index 5dd9c9f..c37efdf 100644
--- a/at.cfg.dist
+++ b/at.cfg.dist
@@ -11,4 +11,9 @@ CLAIMABLE_EXCLUDE = [
# '127.0.0.1',
]
+SPECIAL_DEVICES = {
+ 'kektops': ('90:e6:ba:84'),
+ 'esps': ('ec:fa:bc', 'dc:4f:22', 'd8:a0:1d', 'b4:e6:2d', 'ac:d0:74', 'a4:7b:9d', 'a0:20:a6', '90:97:d5', '68:c6:3a', '60:01:94', '5c:cf:7f', '54:5a:a6', '30:ae:a4', '2c:3a:e8', '24:b2:de', '24:0a:c4', '18:fe:34'),
+}
+
SECRET_KEY = 'adaba'
diff --git a/at.py b/at.py
index 5f545b8..01347bb 100644
--- a/at.py
+++ b/at.py
@@ -254,30 +254,28 @@ def list_all():
def now_at():
+ result = dict()
devices = app.updater.get_active_devices()
device_infos = list(get_device_infos(g.db, devices.keys()))
device_infos.sort(key=lambda di: devices.__getitem__)
all_unknown = set(devices.keys()) - set(d.hwaddr for d in device_infos)
# das kektop sorting maschine
- kektops = set()
- unknown = set()
- esps = set()
- for u in all_unknown:
- if u.startswith('90:e6:ba:84'):
- kektops.add(u)
- elif u.startswith('5c:cf:7f'):
- esps.add(u)
- else:
- unknown.add(u)
+ unknown = all_unknown
+ for name, prefixes in app.config['SPECIAL_DEVICES'].items():
+ result[name] = set()
+ for u in all_unknown:
+ if u.startswith(prefixes):
+ result[name].add(u)
+ unknown.discard(u)
+ result['unknown'] = unknown
users = {}
for info in device_infos:
if info.owner not in users:
users[info.owner] = devices[info.hwaddr][0]
- users_sorted = sorted(users.items(), key=lambda (u, a): a, reverse=True)
+ result['users'] = sorted(users.items(), key=lambda (u, a): a, reverse=True)
- return dict(users=users_sorted, unknown=unknown, kektops=kektops,
- esps=esps)
+ return result
restrict_to_hs = restrict_ip(prefix=app.config['CLAIMABLE_PREFIX'],