mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 16:21:31 +00:00
Make use of format string optimization in logging calls
This commit is contained in:
parent
73ed680298
commit
8eded8cbac
@ -43,7 +43,7 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
|
||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||
return message
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
|
||||
def pause(self, data):
|
||||
self.monitor.pause()
|
||||
|
@ -33,7 +33,7 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
||||
self.processmanager(data['command'], data['process_name'])
|
||||
return message
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
except SupervisorFault as fault:
|
||||
message['data']['error'] = fault.faultString
|
||||
message['data']['log'] = self.processmanager.read_log(message['data']['process_name'])
|
||||
|
@ -110,7 +110,7 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
|
||||
def select(self, data):
|
||||
try: self.filemanager.filename = data['filename']
|
||||
except EnvironmentError: LOG.exception('Failed to select file "{}"'.format(data['filename']))
|
||||
except EnvironmentError: LOG.exception('Failed to select file "%s"', data['filename'])
|
||||
return data
|
||||
|
||||
def select_dir(self, data):
|
||||
@ -123,7 +123,7 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
except IndexError:
|
||||
data['content'] = 'No files in this directory :('
|
||||
except EnvironmentError:
|
||||
LOG.error('Failed to select directory "{}"'.format(data['directory']))
|
||||
LOG.error('Failed to select directory "%s"', data['directory'])
|
||||
return data
|
||||
|
||||
def exclude(self, data):
|
||||
@ -143,7 +143,7 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
self.attach_fileinfo(data)
|
||||
return message
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
|
||||
def cleanup(self):
|
||||
self.monitor.stop()
|
||||
|
@ -23,12 +23,12 @@ class TerminadoEventHandler(TriggerlessEventHandler):
|
||||
return self._historymonitor
|
||||
|
||||
def handle_event(self, key, message):
|
||||
LOG.debug('TerminadoEventHandler received event: {}'.format(message))
|
||||
LOG.debug('TerminadoEventHandler received event: %s', message)
|
||||
try:
|
||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||
return message
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
|
||||
def write(self, data):
|
||||
self.terminado_server.pty.write(data['shellcmd'])
|
||||
|
@ -42,6 +42,6 @@ class TerminadoMiniServer:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
LOG.info('Terminado Mini Server listening on {}'.format(tfwenv.TERMINADO_PORT))
|
||||
LOG.info('Terminado Mini Server listening on %s', tfwenv.TERMINADO_PORT)
|
||||
TerminadoMiniServer('/terminal', tfwenv.TERMINADO_PORT, tfwenv.TERMINADO_WD, ['bash']).listen()
|
||||
IOLoop.instance().start()
|
||||
|
@ -16,7 +16,7 @@ class EventHandlerDownlinkConnector(ZMQConnectorBase):
|
||||
self._zmq_pull_stream = ZMQStream(self._zmq_pull_socket)
|
||||
address = 'tcp://*:{}'.format(tfwenv.RECEIVER_PORT)
|
||||
self._zmq_pull_socket.bind(address)
|
||||
LOG.debug('Pull socket bound to {}'.format(address))
|
||||
LOG.debug('Pull socket bound to %s', address)
|
||||
|
||||
|
||||
class EventHandlerUplinkConnector(ZMQConnectorBase):
|
||||
@ -25,7 +25,7 @@ class EventHandlerUplinkConnector(ZMQConnectorBase):
|
||||
self._zmq_pub_socket = self._zmq_context.socket(zmq.PUB)
|
||||
address = 'tcp://*:{}'.format(tfwenv.PUBLISHER_PORT)
|
||||
self._zmq_pub_socket.bind(address)
|
||||
LOG.debug('Pub socket bound to {}'.format(address))
|
||||
LOG.debug('Pub socket bound to %s', address)
|
||||
|
||||
|
||||
class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector):
|
||||
|
@ -34,7 +34,7 @@ class TFWServer:
|
||||
def make_response(self, message):
|
||||
trigger = message.get('trigger', '')
|
||||
try: self._fsm_manager.trigger(trigger, message)
|
||||
except AttributeError: LOG.debug('FSM failed to execute nonexistent trigger: "{}"'.format(trigger))
|
||||
except AttributeError: LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||
return message
|
||||
|
||||
def proxy_filter(self, message):
|
||||
@ -63,7 +63,7 @@ class FSMManager:
|
||||
|
||||
if all(predicate_results):
|
||||
try: self.fsm.trigger(trigger, message=message)
|
||||
except AttributeError: LOG.debug('FSM failed to execute nonexistent trigger: "{}"'.format(trigger))
|
||||
except AttributeError: LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||
|
||||
def subscribe_predicate(self, trigger, *predicates):
|
||||
self.trigger_predicates[trigger].extend(predicates)
|
||||
|
@ -28,7 +28,7 @@ class ZMQWebSocketHandler(WebSocketHandler):
|
||||
keyhandlers = {'mirror': cls.mirror}
|
||||
|
||||
key, data = deserialize_all(*msg_parts)
|
||||
LOG.debug('Received on pull socket: {}'.format(data))
|
||||
LOG.debug('Received on pull socket: %s', data)
|
||||
if key not in keyhandlers:
|
||||
for instance in cls.instances:
|
||||
instance.write_message(data)
|
||||
@ -42,7 +42,7 @@ class ZMQWebSocketHandler(WebSocketHandler):
|
||||
cls._event_handler_connector.send_message({'data': data}, key)
|
||||
|
||||
def on_message(self, message):
|
||||
LOG.debug('Received on WebSocket: {}'.format(message))
|
||||
LOG.debug('Received on WebSocket: %s', message)
|
||||
self.send_message(self.make_response(message))
|
||||
|
||||
def make_response(self, message):
|
||||
|
Loading…
Reference in New Issue
Block a user