Verified Commit 5966566d authored by Fabio Manganiello's avatar Fabio Manganiello
Browse files

Fixed LGTM warnings

parent 8d26c863
Pipeline #257 passed with stages
in 5 minutes and 27 seconds
......@@ -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:
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment