mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-09-05 17:51:36 +02:00
format MQTT code with ruff
This commit is contained in:
parent
44c07aac12
commit
91d3a7b245
@ -162,7 +162,9 @@ class MqttClient(Communicator):
|
|||||||
def _reason_info(reason_code: object) -> str:
|
def _reason_info(reason_code: object) -> str:
|
||||||
"""Return human_readable_name for a Paho reason code."""
|
"""Return human_readable_name for a Paho reason code."""
|
||||||
# Name string
|
# Name string
|
||||||
if hasattr(reason_code, "getName") and callable(getattr(reason_code, "getName")):
|
if hasattr(reason_code, "getName") and callable(
|
||||||
|
getattr(reason_code, "getName")
|
||||||
|
):
|
||||||
try:
|
try:
|
||||||
name = str(getattr(reason_code, "getName")())
|
name = str(getattr(reason_code, "getName")())
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -195,13 +197,19 @@ class MqttClient(Communicator):
|
|||||||
# Check for connection failure by comparing reason name
|
# Check for connection failure by comparing reason name
|
||||||
if reason_name != "Success":
|
if reason_name != "Success":
|
||||||
if reason_name == "Server unavailable":
|
if reason_name == "Server unavailable":
|
||||||
logger.error("Unable to connect to MQTT server: MQTT Server unavailable")
|
logger.error(
|
||||||
|
"Unable to connect to MQTT server: MQTT Server unavailable"
|
||||||
|
)
|
||||||
elif reason_name == "Bad user name or password":
|
elif reason_name == "Bad user name or password":
|
||||||
logger.error("Unable to connect to MQTT server: MQTT Bad username or password")
|
logger.error(
|
||||||
|
"Unable to connect to MQTT server: MQTT Bad username or password"
|
||||||
|
)
|
||||||
elif reason_name == "Not authorized":
|
elif reason_name == "Not authorized":
|
||||||
logger.error("Unable to connect to MQTT server: MQTT Not authorized")
|
logger.error("Unable to connect to MQTT server: MQTT Not authorized")
|
||||||
else:
|
else:
|
||||||
logger.error(f"Unable to connect to MQTT server: Connection refused. Error: {reason_name}")
|
logger.error(
|
||||||
|
f"Unable to connect to MQTT server: Connection refused. Error: {reason_name}"
|
||||||
|
)
|
||||||
# Don't set connected = True on connection failure
|
# Don't set connected = True on connection failure
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -341,7 +349,7 @@ class MqttClient(Communicator):
|
|||||||
"""Handle MQTT reconnection using fresh client creation, retrying every 10 seconds indefinitely."""
|
"""Handle MQTT reconnection using fresh client creation, retrying every 10 seconds indefinitely."""
|
||||||
logger.error("MQTT reconnection loop started")
|
logger.error("MQTT reconnection loop started")
|
||||||
attempt = 0
|
attempt = 0
|
||||||
|
|
||||||
while not self._stop_reconnect and not self.connected:
|
while not self._stop_reconnect and not self.connected:
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user