summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-05 05:58:33 +0300
committerDevaev Maxim <[email protected]>2020-09-05 05:58:33 +0300
commit0c8524898748c49cd9d54c2dcefa6b4a471532d0 (patch)
treec07a6036d34cf9d9959ce43332f592e3989240ba /kvmd
parente106aaebed430a05721d7279eca8eecdccb13464 (diff)
minor 3.7 fixes
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/aiotools.py1
-rw-r--r--kvmd/apps/kvmd/api/auth.py21
-rw-r--r--kvmd/apps/kvmd/server.py2
-rw-r--r--kvmd/apps/kvmd/ugpio.py26
-rw-r--r--kvmd/keyboard/keysym.py13
5 files changed, 33 insertions, 30 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index 831fe18f..84c6f314 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -177,6 +177,7 @@ async def run_region_task(
if entered.done():
return
+
exc = task.exception()
if exc is not None:
raise exc
diff --git a/kvmd/apps/kvmd/api/auth.py b/kvmd/apps/kvmd/api/auth.py
index 14cd74f4..15c01060 100644
--- a/kvmd/apps/kvmd/api/auth.py
+++ b/kvmd/apps/kvmd/api/auth.py
@@ -64,17 +64,16 @@ async def check_request_auth(auth_manager: AuthManager, exposed: HttpExposed, re
return
basic_auth = request.headers.get("Authorization", "")
- if basic_auth:
- if basic_auth[:6].lower() == "basic ":
- try:
- (user, passwd) = base64.b64decode(basic_auth[6:]).decode("utf-8").split(":")
- except Exception:
- raise UnauthorizedError()
- user = valid_user(user)
- set_request_auth_info(request, f"{user} (basic)")
- if not (await auth_manager.authorize(user, valid_passwd(passwd))):
- raise ForbiddenError()
- return
+ if basic_auth and basic_auth[:6].lower() == "basic ":
+ try:
+ (user, passwd) = base64.b64decode(basic_auth[6:]).decode("utf-8").split(":")
+ except Exception:
+ raise UnauthorizedError()
+ user = valid_user(user)
+ set_request_auth_info(request, f"{user} (basic)")
+ if not (await auth_manager.authorize(user, valid_passwd(passwd))):
+ raise ForbiddenError()
+ return
raise UnauthorizedError()
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py
index 57d8c3e9..9fdf445f 100644
--- a/kvmd/apps/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -216,7 +216,7 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
("resolution", valid_stream_resolution, StreamerResolutionNotSupported),
]:
value = request.query.get(name)
- if (value):
+ if value:
if name not in current_params:
assert exc_cls is not None, name
raise exc_cls()
diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py
index b54c229a..3420ae84 100644
--- a/kvmd/apps/kvmd/ugpio.py
+++ b/kvmd/apps/kvmd/ugpio.py
@@ -258,18 +258,20 @@ class UserGpio:
"type": "label",
"text": item[1:].strip(),
})
- elif (parts := list(map(str.strip, item.split(",", 1)))):
- if parts[0] in self.__inputs:
- items.append({
- "type": "input",
- "channel": parts[0],
- })
- elif parts[0] in self.__outputs:
- items.append({
- "type": "output",
- "channel": parts[0],
- "text": (parts[1] if len(parts) > 1 else "Click"),
- })
+ else:
+ parts = list(map(str.strip, item.split(",", 1)))
+ if parts:
+ if parts[0] in self.__inputs:
+ items.append({
+ "type": "input",
+ "channel": parts[0],
+ })
+ elif parts[0] in self.__outputs:
+ items.append({
+ "type": "output",
+ "channel": parts[0],
+ "text": (parts[1] if len(parts) > 1 else "Click"),
+ })
table.append(items)
return {
"header": self.__view["header"],
diff --git a/kvmd/keyboard/keysym.py b/kvmd/keyboard/keysym.py
index 2f2bc7a2..e3695b3c 100644
--- a/kvmd/keyboard/keysym.py
+++ b/kvmd/keyboard/keysym.py
@@ -130,10 +130,11 @@ def _read_keyboard_layout(path: str) -> Dict[int, At1Key]: # Keysym to evdev (a
ctrl=("ctrl" in rest),
)
- x11_code = _resolve_keysym(parts[0].upper())
- if "addupper" in rest and x11_code != 0:
- layout[x11_code] = At1Key(
- code=at1_code,
- shift=True,
- )
+ if "addupper" in rest:
+ x11_code = _resolve_keysym(parts[0].upper())
+ if x11_code != 0:
+ layout[x11_code] = At1Key(
+ code=at1_code,
+ shift=True,
+ )
return layout