def test_parse_args(self): """ Verify parse_args works properly. """ sys.argv.append('--bus-exchange=test') ns = parse_args(self.parser) self.assertIs(Namespace, type(ns)) self.assertEquals('test', ns.bus_exchange)
def main(): """ Main entry point. """ # Use the same dispatcher global DISPATCHER epilog = 'Example: commissaire -c conf/myconfig.json' parser = argparse.ArgumentParser(epilog=epilog) args = parse_args(parser) try: # Inject the authentication plugin DISPATCHER = inject_authentication(args.authentication_plugins, args.self_auths) # Connect to the bus DISPATCHER.setup_bus(args.bus_exchange, args.bus_uri, [{ 'name': 'simple', 'routing_key': 'simple.*' }]) # Create the server server = CommissaireHttpServer(args.listen_interface, args.listen_port, DISPATCHER, args.tls_pemfile, args.tls_clientverifyfile) # Serve until we are killed off server.serve_forever() except KeyboardInterrupt: # pragma: no cover server.logger.fatal('Received KeyboardInterrupt. Exiting ...') except ImportError: parser.error('Could not import "{}" for authentication'.format( args.authentication_plugins)) except Exception as error: # pragma: no cover from traceback import print_exc print_exc() parser.error('Exception shown above. Error: {}'.format(error))
def main(): """ Main entry point. """ epilog = 'Example: commissaire -c conf/myconfig.json' parser = argparse.ArgumentParser(epilog=epilog) args = parse_args(parser) try: # Inject the authentication plugin if args.authentication_plugin: DISPATCHER = inject_authentication( args.authentication_plugin, args.authentication_plugin_kwargs) # Create the server server = CommissaireHttpServer(args.listen_interface, args.listen_port, DISPATCHER, args.tls_pemfile, args.tls_clientverifyfile) # Set up our bus data server.setup_bus(args.bus_exchange, args.bus_uri, [{ 'name': 'simple', 'routing_key': 'simple.*' }]) # Serve until we are killed off server.serve_forever() except KeyboardInterrupt: # pragma: no cover pass except ImportError: parser.error('Could not import "{}" for authentication'.format( args.authentication_plugin)) except Exception as error: # pragma: no cover from traceback import print_exc print_exc() parser.error('Exception shown above. Error: {}'.format(error))