def main(): if VERSION: print('Addok', VERSION) main_parser = argparse.ArgumentParser(description='Addok command line.', add_help=False) main_parser.add_argument('--config', help='Local config') args, extras = main_parser.parse_known_args() if args.config: os.environ['ADDOK_CONFIG_MODULE'] = args.config main_parser.add_argument('-h', '--help', action='store_true', help='Show this help message and exit') subparsers = main_parser.add_subparsers(title='Available commands', metavar='') from addok import hooks config.load() hooks.register_command(subparsers) args = main_parser.parse_args(args=extras) if getattr(args, 'func', None): args.func(args) else: main_parser.print_help()
def pytest_configure(): # Do not import files from the top of the module, otherwise they will # not taken into account by the coverage. from addok.config import config config.__class__.TESTING = True # Be sure not to load local config during tests. os.environ['ADDOK_CONFIG_MODULE'] = '' import logging logging.basicConfig(level=logging.DEBUG) config.REDIS['db'] = 15 config.load()
def pytest_configure(): from addok.config import config as addok_config addok_config.__class__.TESTING = True # Force test config. from addok import config as config_module os.environ['ADDOK_CONFIG_MODULE'] = str( Path(config_module.__file__).parent / 'test.py') import logging logging.basicConfig(level=logging.DEBUG) addok_config.REDIS['indexes']['db'] = 14 addok_config.REDIS['documents']['db'] = 15 addok_config.load()
def main(): main_parser = argparse.ArgumentParser(description='Addok command line.') main_parser.add_argument('--config', help='Local config') args, extras = main_parser.parse_known_args() if args.config: os.environ['ADDOK_CONFIG_MODULE'] = args.config subparsers = main_parser.add_subparsers(title='Available commands', metavar='') from addok import hooks config.load() hooks.register_command(subparsers) args = main_parser.parse_args(args=extras) if getattr(args, 'func', None): args.func(args) else: main_parser.print_help()
import falcon from addok.config import config, hooks from .base import CorsMiddleware config.load() middlewares = [CorsMiddleware()] hooks.register_api_middleware(middlewares) application = falcon.API(middleware=middlewares) hooks.register_api_endpoint(application) def simple(args): from wsgiref.simple_server import make_server httpd = make_server(args.host, int(args.port), application) print("Serving HTTP on {}:{}…".format(args.host, args.port)) try: httpd.serve_forever() except (KeyboardInterrupt, EOFError): print('Bye!')