def start(): """ Starts baboon client ! """ # Ensure the validity of the configuration file. check_config(add_mandatory_server_fields=['streamer', 'max_stanza_size']) metadirs = [] monitor = None transport = None try: transport = _start_transport() monitor = _start_monitor() metadirs = _start_metadirs(monitor.handler.exclude) # Wait until the transport is disconnected before exiting Baboon. _wait_disconnect(transport) except BaboonException as err: logger.error(err) except KeyboardInterrupt: pass finally: _start_close(monitor, transport, metadirs) logger.info("Bye !")
def unpack(data): """ Unpacks the data. On error, log an error message and returns None. """ try: return pickle.loads(data) except Exception as err: logger.error(err)
def main(): """ The entry point of the Baboon client. """ try: # Call the correct method according to the current arg subparser. getattr(commands, config['parser']['which'])() except (ConfigException, KeyError) as err: logger.error(err) sys.exit(1)