diff --git a/biscd/1 b/biscd/1 deleted file mode 100644 index ca91e8d..0000000 --- a/biscd/1 +++ /dev/null @@ -1 +0,0 @@ -Docker version 18.09.1, build 4c52b90 diff --git a/biscd/biscd/__init__.py b/biscd/biscd/__init__.py index 8c44899..c257280 100644 --- a/biscd/biscd/__init__.py +++ b/biscd/biscd/__init__.py @@ -8,29 +8,14 @@ app = Flask(__name__) Bootstrap(app) def read_config(): - config_template = { - 'config' : { - 'flask_development_server' : { - 'flask_env' : confuse.OneOf(['development', 'production']), - 'server_host' : confuse.String(pattern="^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"), - 'port' : confuse.Integer() - }, - 'logging' : { - 'infofile' : confuse.Filename(), - 'errorfile' : confuse.Filename() - }, - 'message' : confuse.String() - } - } conf = confuse.Configuration('biscd', __name__) - valid = conf.get(config_template) - print('valid', valid) - print('dict', valid.__dict__) - print('message is', valid.config.message) - if False:#not conf.has_section('MISC'): - raise ValueError("Failed to open any configfile containing a MISC section. \ - Please make sure the script dir contains a config.yml, \ - or /etc/{__name__}.conf exists") + try: + conf['config'].get() + except confuse.NotFoundError: + raise ValueError("Failed to open any configfile containing a 'config' object. " \ + "Please make sure the module directory contains a config_default.yaml, " \ + f"or /etc/{__name__}/config.yaml exists") + return conf['config'] config = read_config() diff --git a/biscd/biscd/config_default.yaml b/biscd/biscd/config_default.yaml index 90814f3..7fb6fbb 100644 --- a/biscd/biscd/config_default.yaml +++ b/biscd/biscd/config_default.yaml @@ -1,4 +1,4 @@ -config: +confiag: flask_development_server: # Options: production, development flask_env: development