Make python 3.7 compatible

This commit is contained in:
Dominic Zimmer 2020-07-17 22:17:14 +02:00
parent c8fa4d0dad
commit 9f8bc4b9a4
2 changed files with 5 additions and 4 deletions

View File

@ -24,7 +24,7 @@ def get_client(request: aiohttp.web.Request):
raise aiohttp.web.HTTPBadRequest()
if not model.exists_client(client):
print(f'[get_client] model does not know {client=}')
#print(f'[get_client] model does not know {client=}')
raise aiohttp.web.HTTPBadRequest()
return client
@ -40,7 +40,7 @@ async def handler(request: aiohttp.web.Request):
@routes.get(CLIENT_REGEX + '/')
async def handler(request: aiohttp.web.Request):
client = get_client(request)
print(f"{client=} accessed")
#print(f"{client=} accessed")
return aiohttp.web.FileResponse('ui.html')
@routes.post('/api/token{authtoken}/{method}')

View File

@ -6,8 +6,9 @@ import datetime
import hashlib
def generate_random_id(_s=set()):
while (new_id := base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()) in _s:
pass
newid = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
while (new_id in _s):
newid = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
_s.add(new_id)
return new_id