Flake8 QA
- Ignoring raising BaseExceptions; we can't raise an exception here as it will abort the rest of the execution (in this case, the HTTP or WS request)
This commit is contained in:
@ -81,7 +81,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
content = pickle.load(f)
|
content = pickle.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
return content
|
return content
|
||||||
except Exception:
|
except BaseException: # noqa: B036
|
||||||
if name == "pinned":
|
if name == "pinned":
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
@ -101,7 +101,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
with file_path.open("wb") as f:
|
with file_path.open("wb") as f:
|
||||||
pickle.dump(dict, f, pickle.HIGHEST_PROTOCOL)
|
pickle.dump(dict, f, pickle.HIGHEST_PROTOCOL)
|
||||||
pickle.close()
|
pickle.close()
|
||||||
except Exception:
|
except BaseException: # noqa: B036
|
||||||
return False
|
return False
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -139,7 +139,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
generated = False
|
generated = False
|
||||||
|
|
||||||
# invalid, so just create a default connection, and auto-generate an ID
|
# invalid, so just create a default connection, and auto-generate an ID
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
client_id = self.generateGuid()
|
client_id = self.generateGuid()
|
||||||
connection_id = self.generateGuid()
|
connection_id = self.generateGuid()
|
||||||
username = "Anonymous"
|
username = "Anonymous"
|
||||||
@ -198,7 +198,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
callback(response)
|
callback(response)
|
||||||
else:
|
else:
|
||||||
return response
|
return response
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
error = "Failed to send message to " + data["recipient"]
|
error = "Failed to send message to " + data["recipient"]
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
"params": {"connection": client},
|
"params": {"connection": client},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
logger.error("Failed to close connection to " + connection_id)
|
logger.error("Failed to close connection to " + connection_id)
|
||||||
|
|
||||||
def set_username(self, *args, **kwargs):
|
def set_username(self, *args, **kwargs):
|
||||||
@ -671,7 +671,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
await self.get_spotify_token()
|
await self.get_spotify_token()
|
||||||
spotify_token = self.spotify_token
|
spotify_token = self.spotify_token
|
||||||
access_token = spotify_token["access_token"]
|
access_token = spotify_token["access_token"]
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
error = "IrisFrontend: access_token missing or invalid"
|
error = "IrisFrontend: access_token missing or invalid"
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
return False
|
return False
|
||||||
@ -971,7 +971,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
try:
|
try:
|
||||||
http_client = AsyncHTTPClient()
|
http_client = AsyncHTTPClient()
|
||||||
command_response = await http_client.fetch(request)
|
command_response = await http_client.fetch(request)
|
||||||
except Exception as e:
|
except Exception as e: # noqa: B036
|
||||||
error = {"message": "Command failed", "description": str(e)}
|
error = {"message": "Command failed", "description": str(e)}
|
||||||
if callback:
|
if callback:
|
||||||
callback(False, error)
|
callback(False, error)
|
||||||
@ -982,13 +982,13 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
# Attempt to parse body as JSON
|
# Attempt to parse body as JSON
|
||||||
try:
|
try:
|
||||||
command_response_body = json.loads(command_response.body)
|
command_response_body = json.loads(command_response.body)
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
# Perhaps it requires unicode encoding?
|
# Perhaps it requires unicode encoding?
|
||||||
try:
|
try:
|
||||||
command_response_body = tornado.escape.to_unicode(
|
command_response_body = tornado.escape.to_unicode(
|
||||||
command_response.body
|
command_response.body
|
||||||
)
|
)
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
command_response_body = ""
|
command_response_body = ""
|
||||||
|
|
||||||
# Finally, return the result
|
# Finally, return the result
|
||||||
@ -1038,7 +1038,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
"client_secret": self.config["spotify"]["client_secret"],
|
"client_secret": self.config["spotify"]["client_secret"],
|
||||||
"grant_type": "client_credentials",
|
"grant_type": "client_credentials",
|
||||||
}
|
}
|
||||||
except (Exception):
|
except BaseException: # noqa: B036
|
||||||
error = {
|
error = {
|
||||||
"message": "Could not refresh Spotify token: invalid configuration"
|
"message": "Could not refresh Spotify token: invalid configuration"
|
||||||
}
|
}
|
||||||
@ -1111,7 +1111,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
try:
|
try:
|
||||||
path = request.get_argument("path")
|
path = request.get_argument("path")
|
||||||
url = "https://genius.com" + path
|
url = "https://genius.com" + path
|
||||||
except Exception as e:
|
except Exception as e: # noqa: B036
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
error = {"message": "Path not valid", "description": str(e)}
|
error = {"message": "Path not valid", "description": str(e)}
|
||||||
|
|
||||||
@ -1126,7 +1126,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
+ " not connected",
|
+ " not connected",
|
||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e: # noqa: B036
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
error = {
|
error = {
|
||||||
"message": "Unauthorized request",
|
"message": "Unauthorized request",
|
||||||
@ -1206,7 +1206,7 @@ class IrisCore(pykka.ThreadingActor):
|
|||||||
"message": "Could not update Snapcast meta",
|
"message": "Could not update Snapcast meta",
|
||||||
error: error,
|
error: error,
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e: # noqa: B036
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
response = {"message": "Could not update Snapcast meta"}
|
response = {"message": "Could not update Snapcast meta"}
|
||||||
|
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class WebsocketHandler(tornado.websocket.WebSocketHandler):
|
|||||||
error=error,
|
error=error,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e: # noqa: B036
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -222,7 +222,7 @@ class HttpHandler(tornado.web.RequestHandler):
|
|||||||
id=id, method=slug, response=response, error=error
|
id=id, method=slug, response=response, error=error
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e: # noqa: B036
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -241,7 +241,7 @@ class HttpHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
params = json.loads(self.request.body.decode("utf-8"))
|
params = json.loads(self.request.body.decode("utf-8"))
|
||||||
except BaseException:
|
except BaseException: # noqa: B036
|
||||||
self.handle_result(
|
self.handle_result(
|
||||||
id=id,
|
id=id,
|
||||||
error={"code": 32700, "message": "Missing or invalid payload"},
|
error={"code": 32700, "message": "Missing or invalid payload"},
|
||||||
|
|||||||
Reference in New Issue
Block a user