Skip to content

Commit

Permalink
Merge pull request #430 from BoboTiG/fix-deprecated-log-warn
Browse files Browse the repository at this point in the history
fix: Usage of deprecated `logging.warn()`
  • Loading branch information
jblance committed Dec 11, 2023
2 parents b870a7f + 2f937ea commit 822f4a7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions mppsolar/inout/testio.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def send_and_receive(self, *args, **kwargs) -> dict:
if desired_test_response < number_of_test_responses:
self._test_data = command_defn["test_responses"][desired_test_response]
else:
log.warn(
log.warning(
f"Test response requested: {desired_test_response} exceeds highest id available (IDs start at 0): {number_of_test_responses-1}, returning random one"
)
self._test_data = command_defn["test_responses"][
Expand All @@ -46,7 +46,7 @@ def send_and_receive(self, *args, **kwargs) -> dict:
]
else:
# No test responses defined
log.warn("Testing a command with no test responses defined")
log.warning("Testing a command with no test responses defined")
response = self._test_data
log.debug(f"Raw response {response}")
return response
6 changes: 3 additions & 3 deletions mppsolar/libs/mqttbrokerc.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def connect(self):
self.mqttc.loop_start()
sleep(1)
except ConnectionRefusedError as exc:
log.warn(f"{self.name} refused connection '{exc}'")
log.warning(f"{self.name} refused connection '{exc}'")

def start(self):
if self._isConnected:
Expand Down Expand Up @@ -136,7 +136,7 @@ def subscribe(self, topic, callback):
log.debug(f"Subscribing to topic {topic}")
self.mqttc.subscribe(topic, qos=0)
else:
log.warn(f"Did not subscribe to topic {topic} as not connected to broker")
log.warning(f"Did not subscribe to topic {topic} as not connected to broker")

def publishMultiple(self, data):
for msg in data:
Expand All @@ -153,7 +153,7 @@ def publish(self, topic, payload):
self.connect()
sleep(1)
if not self._isConnected:
log.warn("mqtt broker did not connect")
log.warning("mqtt broker did not connect")
return
try:
infot = self.mqttc.publish(topic, payload)
Expand Down
4 changes: 2 additions & 2 deletions mppsolar/protocols/abstractprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def decode(self, response, command) -> dict:
response_defn = get_resp_defn(lookup_key, command_defn["response"])
if response_defn is None:
# No definition for this key, so ignore???
log.warn(f"No definition for {response}")
log.warning(f"No definition for {response}")
continue
# key = response_defn[0] #0
data_type = response_defn[3] # 1
Expand Down Expand Up @@ -513,7 +513,7 @@ def decode(self, response, command) -> dict:
response_defn = command_defn["response"][i]
if response_defn is None:
# No definition for this key, so ignore???
log.warn(f"No definition for {response}")
log.warning(f"No definition for {response}")
response_defn = [
"str",
1,
Expand Down
2 changes: 1 addition & 1 deletion mppsolar/protocols/ved.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def get_full_command(self, command) -> bytes:
cmd = f":{cmd}{checksum:02X}\n"
log.debug(f"full command: {cmd}")
return cmd
log.warn("unable to generate full command - is the definition wrong?")
log.warning("unable to generate full command - is the definition wrong?")
return None

def check_response_valid(self, response) -> Tuple[bool, dict]:
Expand Down
4 changes: 2 additions & 2 deletions powermon/commands/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def is_due(self) -> bool:
return False
elif self.trigger_type == TriggerType.AT:
if self.next_run is None:
#log.warn("at type trigger failed to set next run for %s" % command)
#log.warning("at type trigger failed to set next run for %s" % command)
return False
if self.next_run <= now:
return True
Expand All @@ -107,7 +107,7 @@ def is_due(self) -> bool:
return True
else:
return False
#log.warn("no isDue set for %s" % command)
#log.warning("no isDue set for %s" % command)
return False

def determine_next_run(self) -> float:
Expand Down
6 changes: 3 additions & 3 deletions powermon/libs/mqttbroker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def connect(self):
self.mqttc.loop_start()
sleep(1)
except ConnectionRefusedError as exc:
log.warn(f"{self.name} refused connection '{exc}'")
log.warning(f"{self.name} refused connection '{exc}'")

def start(self):
if self.disabled:
Expand Down Expand Up @@ -146,7 +146,7 @@ def subscribe(self, topic, callback):
log.debug(f"Subscribing to topic {topic}")
self.mqttc.subscribe(topic, qos=0)
else:
log.warn(f"Did not subscribe to topic {topic} as not connected to broker")
log.warning(f"Did not subscribe to topic {topic} as not connected to broker")

def publishMultiple(self, data):
if self.disabled:
Expand All @@ -169,7 +169,7 @@ def publish(self, topic, payload):
self.connect()
sleep(1)
if not self._isConnected:
log.warn("mqtt broker did not connect")
log.warning("mqtt broker did not connect")
return
try:
infot = self.mqttc.publish(topic, payload)
Expand Down
2 changes: 1 addition & 1 deletion powermon/outputs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def parseOutputConfig(outputConfig):
# return outputs
else:
# miss configured output?
log.warn("outputConfig (%s) doesnt match expectations, defaulting", outputConfig)
log.warning("outputConfig (%s) doesnt match expectations, defaulting", outputConfig)
outputType = DEFAULT_OUTPUT
formatConfig = DEFAULT_FORMAT

Expand Down

0 comments on commit 822f4a7

Please sign in to comment.