From 5966566d540a4132c2a2ac099c7c3b90b5d86858 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 10 Jun 2022 20:56:06 +0200 Subject: [PATCH] Fixed LGTM warnings --- platypush/backend/http/app/routes/execute.py | 14 +++++++++----- platypush/backend/http/app/routes/logout.py | 12 +++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/platypush/backend/http/app/routes/execute.py b/platypush/backend/http/app/routes/execute.py index cfbabe175..770dddf28 100644 --- a/platypush/backend/http/app/routes/execute.py +++ b/platypush/backend/http/app/routes/execute.py @@ -16,12 +16,14 @@ __routes__ = [ @execute.route('/execute', methods=['POST']) @authenticate() def execute(): - """ Endpoint to execute commands """ + """Endpoint to execute commands""" try: msg = json.loads(request.data.decode('utf-8')) except Exception as e: - logger().error('Unable to parse JSON from request {}: {}'.format(request.data, str(e))) - return abort(400, str(e)) + logger().error( + 'Unable to parse JSON from request {}: {}'.format(request.data, str(e)) + ) + abort(400, str(e)) logger().info('Received message on the HTTP backend: {}'.format(msg)) @@ -29,8 +31,10 @@ def execute(): response = send_message(msg) return Response(str(response or {}), mimetype='application/json') except Exception as e: - logger().error('Error while running HTTP action: {}. Request: {}'.format(str(e), msg)) - return abort(500, str(e)) + logger().error( + 'Error while running HTTP action: {}. Request: {}'.format(str(e), msg) + ) + abort(500, str(e)) # vim:sw=4:ts=4:et: diff --git a/platypush/backend/http/app/routes/logout.py b/platypush/backend/http/app/routes/logout.py index 17fc36def..72c68a812 100644 --- a/platypush/backend/http/app/routes/logout.py +++ b/platypush/backend/http/app/routes/logout.py @@ -13,17 +13,19 @@ __routes__ = [ @logout.route('/logout', methods=['GET', 'POST']) def logout(): - """ Logout page """ + """Logout page""" user_manager = UserManager() - redirect_page = request.args.get('redirect', request.headers.get('Referer', '/login')) + redirect_page = request.args.get( + 'redirect', request.headers.get('Referer', '/login') + ) session_token = request.cookies.get('session_token') if not session_token: - return abort(417, 'Not logged in') + abort(417, 'Not logged in') - user, session = user_manager.authenticate_user_session(session_token) + user, _ = user_manager.authenticate_user_session(session_token) if not user: - return abort(403, 'Invalid session token') + abort(403, 'Invalid session token') redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection] response = make_response(redirect_target)