def main(global_config, **settings): """Main WSGI application factory.""" _set_settings(settings) # Initialize logging logging_config_filepath = settings.get('logging-configuration-filepath', DEFAULT_LOGGING_CONFIG_FILEPATH) load_logging_configuration(logging_config_filepath) app = Application() app.add_route('/contents/{ident_hash:.*}.html', 'cnxarchive.views:get_content_html') app.add_route('/contents/{ident_hash:.*}.json', 'cnxarchive.views:get_content_json') # app.add_route('/contents/{ident_hash}.snippet', 'cnxarchive.views:get_content_snippet') app.add_route('/contents/{ident_hash}', 'cnxarchive.views:get_content') app.add_route('/resources/{hash}', 'cnxarchive.views:get_resource') app.add_route('/exports/{ident_hash}.{type}{ignore:(/.*)?}', 'cnxarchive.views:get_export') app.add_route('/extras/{ident_hash}', 'cnxarchive.views:get_extra') app.add_route('/search', 'cnxarchive.views:search') app.add_route('/extras', 'cnxarchive.views:extras') app.add_route('/sitemap.xml', 'cnxarchive.views:sitemap') mandatory_settings = ['exports-directories', 'exports-allowable-types'] for setting in mandatory_settings: if not settings.get(setting, None): raise ValueError('Missing {} configuration setting.'.format(setting)) return app
def main(argv=None): """Command line utility""" parser = argparse.ArgumentParser(description="PyBit builder for rhaptos") parser.add_argument('config', type=argparse.FileType('r'), help="INI configuration file") args = parser.parse_args(argv) load_logging_configuration(args.config) # Re-spool the file for a future read. args.config.seek(0) # Load the configuration global config config = Config.from_file(args.config) host = config.amqp.get('host', 'localhost') port = int(config.amqp.get('port', 5672)) user = config.amqp.get('user') password = config.amqp.get('password') virtual_host = config.amqp.get('virtual_host') credentials = pika.PlainCredentials(user, password) parameters = pika.ConnectionParameters(host, port, virtual_host, credentials) connection = pika.SelectConnection(parameters, on_connected) try: # Loop so we can communicate with RabbitMQ connection.ioloop.start() except KeyboardInterrupt: # Gracefully close the connection connection.close() # Loop until we're fully closed, will stop on its own connection.ioloop.start()
def main(argv=None): """Command line utility""" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('config', type=argparse.FileType('r'), help="INI configuration file") args = parser.parse_args(argv) load_logging_configuration(args.config) # Re-spool the file for a future read. args.config.seek(0) # Load the configuration global config config = Config.from_file(args.config) connection = make_connection(config) try: # Loop so we can communicate with RabbitMQ connection.ioloop.start() except KeyboardInterrupt: # Gracefully close the connection connection.close() # Loop until we're fully closed, will stop on its own connection.ioloop.start()