summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvuko <vuko@hackerspace.pl>2020-06-07 13:28:15 +0200
committervuko <vuko@hackerspace.pl>2020-06-07 13:28:15 +0200
commit13110667b58710f243c5c37fa921aa60e8ef38a8 (patch)
tree74f01972b520b019df68c4a153a358e1039ed54c
parent35e30cd74ae17584eedbee5aa50a1c7fa843baf9 (diff)
downloadcheckinator-13110667b58710f243c5c37fa921aa60e8ef38a8.tar.gz
checkinator-13110667b58710f243c5c37fa921aa60e8ef38a8.tar.bz2
checkinator-13110667b58710f243c5c37fa921aa60e8ef38a8.zip
running python 2to3 on at.py
-rw-r--r--at.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/at.py b/at.py
index 1fd0b5c..c50ddd8 100644
--- a/at.py
+++ b/at.py
@@ -13,7 +13,7 @@ from flask import Flask, render_template, abort, g, \
from datetime import datetime
from time import sleep, time, mktime
from collections import namedtuple
-from urllib import urlencode
+from urllib.parse import urlencode
from spaceauth import SpaceAuth, login_required, current_user, cap_required
@@ -58,7 +58,7 @@ def restrict_ip(prefix='', exclude=[]):
def req_to_ctx():
- return dict(request.form.iteritems())
+ return dict(iter(request.form.items()))
@app.template_filter('strfts')
@@ -112,7 +112,7 @@ class Updater(threading.Thread):
def purge_stale(self):
now = time()
- for addr, (atime, ip, name) in self.active.items():
+ for addr, (atime, ip, name) in list(self.active.items()):
if now - atime > self.timeout:
del self.active[addr]
@@ -124,7 +124,7 @@ class Updater(threading.Thread):
return r
def get_device(self, ip):
- active_devices = self.get_active_devices().iteritems()
+ active_devices = iter(self.get_active_devices().items())
for hwaddr, (atime, dip, name) in active_devices:
if ip == dip:
return hwaddr, name
@@ -243,15 +243,16 @@ def main_view():
def list_all():
data = now_at()
- def prettify_user((user, atime)):
+ def prettify_user(xxx_todo_changeme):
+ (user, atime) = xxx_todo_changeme
return {
'login': user,
'timestamp': atime,
'pretty_time': strfts(atime),
}
result = {}
- result['users'] = map(prettify_user, data.pop('users'))
- result.update((k, len(v)) for k, v in data.items())
+ result['users'] = list(map(prettify_user, data.pop('users')))
+ result.update((k, len(v)) for k, v in list(data.items()))
res = make_response(json.dumps(result), 200)
res.headers['Access-Control-Allow-Origin'] = '*'
return res
@@ -260,11 +261,11 @@ 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 = list(get_device_infos(g.db, list(devices.keys())))
device_infos.sort(key=lambda di: devices.__getitem__)
unknown = set(devices.keys()) - set(d.hwaddr for d in device_infos)
# das kektop sorting maschine
- for name, prefixes in app.config['SPECIAL_DEVICES'].items():
+ for name, prefixes in list(app.config['SPECIAL_DEVICES'].items()):
result[name] = set()
for u in unknown.copy():
if u.startswith(prefixes):
@@ -277,7 +278,7 @@ def now_at():
for info in device_infos:
if info.owner not in users:
users[info.owner] = devices[info.hwaddr][0]
- result['users'] = sorted(users.items(), key=lambda (u, a): a, reverse=True)
+ result['users'] = sorted(list(users.items()), key=lambda u_a: u_a[1], reverse=True)
return result