Skip to content

Commit

Permalink
Replace deprecated logger.warn with .warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tofu-rocketry committed Aug 13, 2021
1 parent 21831dc commit fe138ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_protocol(cp, log):
# If the newer configuration setting 'protocol' is not set, use 'STOMP'
# for backwards compatability.
protocol = Ssm2.STOMP_MESSAGING
log.warn("No option set for 'protocol'. Defaulting to %s.", protocol)
log.warning("No option set for 'protocol'. Defaulting to %s.", protocol)
except ValueError:
log.critical("Invalid protocol '%s' set. Must be either '%s' or '%s'.",
protocol, Ssm2.STOMP_MESSAGING, Ssm2.AMS_MESSAGING)
Expand Down Expand Up @@ -315,7 +315,7 @@ def run_receiver(protocol, brokers, project, token, cp, log, dn_file):
ssm.send_ping()

except (NotConnectedException, AmsConnectionException) as error:
log.warn('Connection lost.')
log.warning('Connection lost.')
log.debug(error)
ssm.shutdown()
dc.close()
Expand Down Expand Up @@ -355,7 +355,7 @@ def get_dns(dn_file, log):
elif line.strip().startswith('/'):
dns.append(line.strip())
else:
log.warn('DN in incorrect format: %s', line)
log.warning('DN in incorrect format: %s', line)
finally:
if f is not None:
f.close()
Expand Down
22 changes: 11 additions & 11 deletions ssm/ssm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _handle_msg(self, text):
"""
if text is None or text == '':
warning = 'Empty text passed to _handle_msg.'
log.warn(warning)
log.warning(warning)
return None, None, warning
# if not text.startswith('MIME-Version: 1.0'):
# raise Ssm2Exception('Not a valid message.')
Expand All @@ -313,7 +313,7 @@ def _handle_msg(self, text):

if signer not in self._valid_dns:
warning = 'Signer not in valid DNs list: %s' % signer
log.warn(warning)
log.warning(warning)
return None, signer, warning
else:
log.info('Valid signer: %s', signer)
Expand All @@ -335,7 +335,7 @@ def _save_msg_to_queue(self, body, empaid):
# allows the msg to be reloaded if needed.
body = extracted_msg

log.warn("Message rejected: %s", err_msg)
log.warning("Message rejected: %s", err_msg)

name = self._rejectq.add({'body': body,
'signer': signer,
Expand Down Expand Up @@ -474,7 +474,7 @@ def send_all(self):
log.info('Found %s messages.', self._outq.count())
for msgid in self._outq:
if not self._outq.lock(msgid):
log.warn('Message was locked. %s will not be sent.', msgid)
log.warning('Message was locked. %s will not be sent.', msgid)
continue

text = self._outq.get(msgid)
Expand Down Expand Up @@ -514,7 +514,7 @@ def send_all(self):
# Remove empty dirs and unlock msgs older than 5 min (default)
self._outq.purge()
except OSError as e:
log.warn('OSError raised while purging message queue: %s', e)
log.warning('OSError raised while purging message queue: %s', e)

###########################################################################
# Connection handling methods
Expand Down Expand Up @@ -563,9 +563,9 @@ def handle_connect(self):
break
except ConnectFailedException as e:
# ConnectFailedException doesn't provide a message.
log.warn('Failed to connect to %s:%s.', host, port)
log.warning('Failed to connect to %s:%s.', host, port)
except Ssm2Exception as e:
log.warn('Failed to connect to %s:%s: %s', host, port, e)
log.warning('Failed to connect to %s:%s: %s', host, port, e)

if not self.connected:
raise Ssm2Exception('Attempts to start the SSM failed. The system will exit.')
Expand Down Expand Up @@ -660,7 +660,7 @@ def startup(self):
f.write('\n')
f.close()
except IOError as e:
log.warn('Failed to create pidfile %s: %s', self._pidfile, e)
log.warning('Failed to create pidfile %s: %s', self._pidfile, e)

self.handle_connect()

Expand All @@ -672,7 +672,7 @@ def shutdown(self):
if os.path.exists(self._pidfile):
os.remove(self._pidfile)
else:
log.warn('pidfile %s not found.', self._pidfile)
log.warning('pidfile %s not found.', self._pidfile)
except IOError as e:
log.warn('Failed to remove pidfile %s: %e', self._pidfile, e)
log.warn('SSM may not start again until it is removed.')
log.warning('Failed to remove pidfile %s: %e', self._pidfile, e)
log.warning('SSM may not start again until it is removed.')

0 comments on commit fe138ca

Please sign in to comment.