Change deprecated warn() to warning()

pull/8/head
Stein Magnus Jodal 2017-07-26 14:06:02 +02:00
rodzic 8b1aa60587
commit a89e744a47
5 zmienionych plików z 19 dodań i 19 usunięć

Wyświetl plik

@ -217,7 +217,7 @@ class Broker:
self.transitions.start() self.transitions.start()
self.logger.debug("Broker starting") self.logger.debug("Broker starting")
except MachineError as me: except MachineError as me:
self.logger.warn("[WARN-0001] Invalid method call at this moment: %s" % me) self.logger.warning("[WARN-0001] Invalid method call at this moment: %s" % me)
raise BrokerException("Broker instance can't be started: %s" % me) raise BrokerException("Broker instance can't be started: %s" % me)
yield from self.plugins_manager.fire_event(EVENT_BROKER_PRE_START) yield from self.plugins_manager.fire_event(EVENT_BROKER_PRE_START)
@ -350,7 +350,7 @@ class Broker:
try: try:
handler, client_session = yield from BrokerProtocolHandler.init_from_connect(reader, writer, self.plugins_manager, loop=self._loop) handler, client_session = yield from BrokerProtocolHandler.init_from_connect(reader, writer, self.plugins_manager, loop=self._loop)
except HBMQTTException as exc: except HBMQTTException as exc:
self.logger.warn("[MQTT-3.1.0-1] %s: Can't read first packet an CONNECT: %s" % self.logger.warning("[MQTT-3.1.0-1] %s: Can't read first packet an CONNECT: %s" %
(format_client_message(address=remote_address, port=remote_port), exc)) (format_client_message(address=remote_address, port=remote_port), exc))
#yield from writer.close() #yield from writer.close()
self.logger.debug("Connection closed") self.logger.debug("Connection closed")
@ -474,10 +474,10 @@ class Broker:
self.logger.debug("%s handling message delivery" % client_session.client_id) self.logger.debug("%s handling message delivery" % client_session.client_id)
app_message = wait_deliver.result() app_message = wait_deliver.result()
if not app_message.topic: if not app_message.topic:
self.logger.warn("[MQTT-4.7.3-1] - %s invalid TOPIC sent in PUBLISH message, closing connection" % client_session.client_id) self.logger.warning("[MQTT-4.7.3-1] - %s invalid TOPIC sent in PUBLISH message, closing connection" % client_session.client_id)
break break
if "#" in app_message.topic or "+" in app_message.topic: if "#" in app_message.topic or "+" in app_message.topic:
self.logger.warn("[MQTT-3.3.2-2] - %s invalid TOPIC sent in PUBLISH message, closing connection" % client_session.client_id) self.logger.warning("[MQTT-3.3.2-2] - %s invalid TOPIC sent in PUBLISH message, closing connection" % client_session.client_id)
break break
yield from self.plugins_manager.fire_event(EVENT_BROKER_MESSAGE_RECEIVED, yield from self.plugins_manager.fire_event(EVENT_BROKER_MESSAGE_RECEIVED,
client_id=client_session.client_id, client_id=client_session.client_id,

Wyświetl plik

@ -167,7 +167,7 @@ class MQTTClient:
yield from self._handler.stop() yield from self._handler.stop()
self.session.transitions.disconnect() self.session.transitions.disconnect()
else: else:
self.logger.warn("Client session is not currently connected, ignoring call") self.logger.warning("Client session is not currently connected, ignoring call")
@asyncio.coroutine @asyncio.coroutine
def reconnect(self, cleansession=None): def reconnect(self, cleansession=None):
@ -185,7 +185,7 @@ class MQTTClient:
""" """
if self.session.transitions.is_connected(): if self.session.transitions.is_connected():
self.logger.warn("Client already connected") self.logger.warning("Client already connected")
return CONNECTION_ACCEPTED return CONNECTION_ACCEPTED
if cleansession: if cleansession:
@ -231,7 +231,7 @@ class MQTTClient:
if self.session.transitions.is_connected(): if self.session.transitions.is_connected():
yield from self._handler.mqtt_ping() yield from self._handler.mqtt_ping()
else: else:
self.logger.warn("MQTT PING request incompatible with current session state '%s'" % self.logger.warning("MQTT PING request incompatible with current session state '%s'" %
self.session.transitions.state) self.session.transitions.state)
@mqtt_connected @mqtt_connected
@ -366,7 +366,7 @@ class MQTTClient:
if secure: if secure:
if self.session.cafile is None or self.session.cafile == '': if self.session.cafile is None or self.session.cafile == '':
self.logger.warn("TLS connection can't be estabilshed, no certificate file (.cert) given") self.logger.warning("TLS connection can't be estabilshed, no certificate file (.cert) given")
raise ClientException("TLS connection can't be estabilshed, no certificate file (.cert) given") raise ClientException("TLS connection can't be estabilshed, no certificate file (.cert) given")
sc = ssl.create_default_context( sc = ssl.create_default_context(
ssl.Purpose.SERVER_AUTH, ssl.Purpose.SERVER_AUTH,
@ -416,15 +416,15 @@ class MQTTClient:
self.logger.debug("connected to %s:%s" % (self.session.remote_address, self.session.remote_port)) self.logger.debug("connected to %s:%s" % (self.session.remote_address, self.session.remote_port))
return return_code return return_code
except InvalidURI as iuri: except InvalidURI as iuri:
self.logger.warn("connection failed: invalid URI '%s'" % self.session.broker_uri) self.logger.warning("connection failed: invalid URI '%s'" % self.session.broker_uri)
self.session.transitions.disconnect() self.session.transitions.disconnect()
raise ConnectException("connection failed: invalid URI '%s'" % self.session.broker_uri, iuri) raise ConnectException("connection failed: invalid URI '%s'" % self.session.broker_uri, iuri)
except InvalidHandshake as ihs: except InvalidHandshake as ihs:
self.logger.warn("connection failed: invalid websocket handshake") self.logger.warning("connection failed: invalid websocket handshake")
self.session.transitions.disconnect() self.session.transitions.disconnect()
raise ConnectException("connection failed: invalid websocket handshake", ihs) raise ConnectException("connection failed: invalid websocket handshake", ihs)
except (ProtocolHandlerException, ConnectionError, OSError) as e: except (ProtocolHandlerException, ConnectionError, OSError) as e:
self.logger.warn("MQTT connection failed: %r" % e) self.logger.warning("MQTT connection failed: %r" % e)
self.session.transitions.disconnect() self.session.transitions.disconnect()
raise ConnectException(e) raise ConnectException(e)

Wyświetl plik

@ -12,12 +12,12 @@ class BaseAuthPlugin:
try: try:
self.auth_config = self.context.config['auth'] self.auth_config = self.context.config['auth']
except KeyError: except KeyError:
self.context.logger.warn("'auth' section not found in context configuration") self.context.logger.warning("'auth' section not found in context configuration")
def authenticate(self, *args, **kwargs): def authenticate(self, *args, **kwargs):
if not self.auth_config: if not self.auth_config:
# auth config section not found # auth config section not found
self.context.logger.warn("'auth' section not found in context configuration") self.context.logger.warning("'auth' section not found in context configuration")
return False return False
return True return True
@ -44,7 +44,7 @@ class AnonymousAuthPlugin(BaseAuthPlugin):
else: else:
self.context.logger.debug("Authentication failure: session has an empty username") self.context.logger.debug("Authentication failure: session has an empty username")
except KeyError: except KeyError:
self.context.logger.warn("Session informations not available") self.context.logger.warning("Session informations not available")
authenticated = False authenticated = False
return authenticated return authenticated
@ -70,7 +70,7 @@ class FileAuthPlugin(BaseAuthPlugin):
self.context.logger.debug("user %s , hash=%s" % (username, pwd_hash)) self.context.logger.debug("user %s , hash=%s" % (username, pwd_hash))
self.context.logger.debug("%d user(s) read from file %s" % (len(self._users), password_file)) self.context.logger.debug("%d user(s) read from file %s" % (len(self._users), password_file))
except FileNotFoundError: except FileNotFoundError:
self.context.logger.warn("Password file %s not found" % password_file) self.context.logger.warning("Password file %s not found" % password_file)
else: else:
self.context.logger.debug("Configuration parameter 'password_file' not found") self.context.logger.debug("Configuration parameter 'password_file' not found")

Wyświetl plik

@ -77,9 +77,9 @@ class PluginManager:
obj = plugin(plugin_context) obj = plugin(plugin_context)
return Plugin(ep.name, ep, obj) return Plugin(ep.name, ep, obj)
except ImportError as ie: except ImportError as ie:
self.logger.warn("Plugin %r import failed: %s" % (ep, ie)) self.logger.warning("Plugin %r import failed: %s" % (ep, ie))
except pkg_resources.UnknownExtra as ue: except pkg_resources.UnknownExtra as ue:
self.logger.warn("Plugin %r dependencies resolution failed: %s" % (ep, ue)) self.logger.warning("Plugin %r dependencies resolution failed: %s" % (ep, ue))
def get_plugin(self, name): def get_plugin(self, name):
""" """

Wyświetl plik

@ -16,12 +16,12 @@ class SQLitePlugin:
self.persistence_config = self.context.config['persistence'] self.persistence_config = self.context.config['persistence']
self.init_db() self.init_db()
except KeyError: except KeyError:
self.context.logger.warn("'persistence' section not found in context configuration") self.context.logger.warning("'persistence' section not found in context configuration")
def init_db(self): def init_db(self):
self.db_file = self.persistence_config.get('file', None) self.db_file = self.persistence_config.get('file', None)
if not self.db_file: if not self.db_file:
self.context.logger.warn("'file' persistence parameter not found") self.context.logger.warning("'file' persistence parameter not found")
else: else:
try: try:
self.conn = sqlite3.connect(self.db_file) self.conn = sqlite3.connect(self.db_file)