[cli] .halfapi/domains.

This commit is contained in:
Joël Maïzi 2020-08-05 10:04:20 +02:00
parent 15a63f3713
commit ceaf2774bf
2 changed files with 8 additions and 6 deletions

View File

@ -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(

View File

@ -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')]