moonraker: explicitly declare "None" when calling dict.pop()
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
00d36a5a06
commit
45bed374ea
|
@ -72,7 +72,7 @@ class MutableRouter(tornado.web.ReversibleRuleRouter):
|
|||
self.rules.append(new_rule)
|
||||
|
||||
def remove_handler(self, pattern):
|
||||
rule = self.pattern_to_rule.pop(pattern)
|
||||
rule = self.pattern_to_rule.pop(pattern, None)
|
||||
if rule is not None:
|
||||
try:
|
||||
self.rules.remove(rule)
|
||||
|
|
|
@ -96,12 +96,12 @@ class Authorization:
|
|||
if cur_time - access_time > CONNECTION_TIMEOUT:
|
||||
expired_conns.append(ip)
|
||||
for ip in expired_conns:
|
||||
self.trusted_connections.pop(ip)
|
||||
self.trusted_connections.pop(ip, None)
|
||||
logging.info(
|
||||
"Trusted Connection Expired, IP: %s" % (ip))
|
||||
|
||||
def _token_expire_handler(self, token):
|
||||
self.access_tokens.pop(token)
|
||||
self.access_tokens.pop(token, None)
|
||||
|
||||
def is_enabled(self):
|
||||
return self.auth_enabled
|
||||
|
@ -129,7 +129,7 @@ class Authorization:
|
|||
|
||||
def _check_access_token(self, token):
|
||||
if token in self.access_tokens:
|
||||
token_handler = self.access_tokens.pop(token)
|
||||
token_handler = self.access_tokens.pop(token, None)
|
||||
IOLoop.current().remove_timeout(token_handler)
|
||||
return True
|
||||
else:
|
||||
|
|
|
@ -281,10 +281,10 @@ class Server:
|
|||
if name not in valid_plugins:
|
||||
if hasattr(plugin, "close"):
|
||||
await plugin.close()
|
||||
self.plugins.pop(name)
|
||||
self.plugins.pop(name, None)
|
||||
|
||||
def _handle_klippy_response(self, request_id, response):
|
||||
req = self.pending_requests.pop(request_id)
|
||||
req = self.pending_requests.pop(request_id, None)
|
||||
if req is not None:
|
||||
if isinstance(response, dict) and 'error' in response:
|
||||
response = ServerError(response['message'], 400)
|
||||
|
@ -321,7 +321,7 @@ class Server:
|
|||
self.pending_requests[base_request.id] = base_request
|
||||
ret = self.klippy_send(base_request.to_dict())
|
||||
if not ret:
|
||||
self.pending_requests.pop(base_request.id)
|
||||
self.pending_requests.pop(base_request.id, None)
|
||||
base_request.notify(
|
||||
ServerError("Klippy Host not connected", 503))
|
||||
return base_request
|
||||
|
|
|
@ -19,7 +19,7 @@ class JsonRPC:
|
|||
self.methods[name] = method
|
||||
|
||||
def remove_method(self, name):
|
||||
self.methods.pop(name)
|
||||
self.methods.pop(name, None)
|
||||
|
||||
async def dispatch(self, data):
|
||||
response = None
|
||||
|
@ -183,7 +183,7 @@ class WebsocketManager:
|
|||
try:
|
||||
ws.write_message(notification)
|
||||
except WebSocketClosedError:
|
||||
self.websockets.pop(ws.uid)
|
||||
self.websockets.pop(ws.uid, None)
|
||||
logging.info("Websocket Removed: %d" % ws.uid)
|
||||
except Exception:
|
||||
logging.exception(
|
||||
|
|
Loading…
Reference in New Issue