Remove all uses of assignment expressions.

This is needed to port to Python 3.7 because
Raspbian 10 doesn't have Python 3.8.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
This commit is contained in:
Oleg Girko
2020-08-18 03:44:06 +03:00
parent 5307765399
commit 2dbf11428f
9 changed files with 30 additions and 18 deletions

View File

@@ -45,7 +45,8 @@ _COOKIE_AUTH_TOKEN = "auth_token"
async def check_request_auth(auth_manager: AuthManager, exposed: HttpExposed, request: Request) -> None:
if exposed.auth_required and auth_manager.is_auth_enabled():
if (user := request.headers.get("X-KVMD-User", "")):
user = request.headers.get("X-KVMD-User", "")
if user:
user = valid_user(user)
passwd = request.headers.get("X-KVMD-Passwd", "")
set_request_auth_info(request, f"{user} (xhdr)")
@@ -53,7 +54,8 @@ async def check_request_auth(auth_manager: AuthManager, exposed: HttpExposed, re
raise ForbiddenError()
return
elif (token := request.cookies.get(_COOKIE_AUTH_TOKEN, "")):
token = request.cookies.get(_COOKIE_AUTH_TOKEN, "")
if token:
user = auth_manager.check(valid_auth_token(token))
if not user:
set_request_auth_info(request, "- (token)")
@@ -61,7 +63,8 @@ async def check_request_auth(auth_manager: AuthManager, exposed: HttpExposed, re
set_request_auth_info(request, f"{user} (token)")
return
elif (basic_auth := request.headers.get("Authorization", "")):
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(":")

View File

@@ -56,11 +56,12 @@ class StreamerApi:
@exposed_http("GET", "/streamer/snapshot")
async def __take_snapshot_handler(self, request: Request) -> Response:
if (snapshot := await self.__streamer.take_snapshot(
snapshot = await self.__streamer.take_snapshot(
save=valid_bool(request.query.get("save", "false")),
load=valid_bool(request.query.get("load", "false")),
allow_offline=valid_bool(request.query.get("allow_offline", "false")),
)):
)
if snapshot:
if valid_bool(request.query.get("preview", "false")):
data = await self.__make_preview(
snapshot=snapshot,