From ceaf2774bf7f6441d130bf6bbd185054ba0f3dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Ma=C3=AFzi?= Date: Wed, 5 Aug 2020 10:04:20 +0200 Subject: [PATCH] [cli] .halfapi/domains. --- halfapi/cli/__init__.py | 4 +--- halfapi/conf.py | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/halfapi/cli/__init__.py b/halfapi/cli/__init__.py index 2e0810f..d5160a1 100644 --- a/halfapi/cli/__init__.py +++ b/halfapi/cli/__init__.py @@ -14,7 +14,6 @@ from halfapi import __version__ from halfapi.cli.lib.db import ProjectDB CONTEXT_SETTINGS = { - 'default_map':{'run': {}} } TMPL_HALFAPI_ETC = """Insert this into the HALFAPI_CONF_DIR/{project} file @@ -66,7 +65,6 @@ def run(host, port): click.echo('Launching application') sys.path.insert(0, BASE_DIR) - click.echo(f'current python_path : {sys.path}') uvicorn.run('halfapi.app:application', host=host, @@ -367,7 +365,7 @@ def init_project(project, repo): raise e os.mkdir(os.path.join(project, '.halfapi')) - open(os.path.join(project, '.halfapi', 'domains'), 'w').write('') + open(os.path.join(project, '.halfapi', 'domains'), 'w').write('[domains]\n') config_file = os.path.join(project, '.halfapi', 'config') with open(config_file, 'w') as f: f.write(TMPL_HALFAPI_CONFIG.format( diff --git a/halfapi/conf.py b/halfapi/conf.py index d0be08f..9171cf2 100644 --- a/halfapi/conf.py +++ b/halfapi/conf.py @@ -16,7 +16,7 @@ default_config = { config = ConfigParser(allow_no_value=True) config.read_dict(default_config) -config.read(filenames=['.halfapiconfig']) +config.read(filenames=['.halfapi/config']) PROJECT_NAME = config.get('project', 'name') @@ -24,6 +24,12 @@ if len(PROJECT_NAME) == 0: raise Exception('Need a project name as argument') +config = ConfigParser(allow_no_value=True) +config.read_dict(default_config) +config.read(filenames=['.halfapi/domains']) + +DOMAINS = [domain for domain, _ in config.items('domains')] + CONF_DIR = environ.get('HALFAPI_CONF_DIR', '/etc/half_api') config.read(filenames=[os.path.join( @@ -40,5 +46,3 @@ with open(config.get('project', 'secret')) as secret_file: PRODUCTION = config.getboolean('project', 'production') BASE_DIR = config.get('project', 'base_dir') - -DOMAINS = [domain for domain, _ in config.items('domains')]