Browse Source

Remove config template checking

master
Burathar 4 years ago
parent
commit
86db110b32
  1. 1
      biscd/1
  2. 29
      biscd/biscd/__init__.py
  3. 2
      biscd/biscd/config_default.yaml

1
biscd/1

@ -1 +0,0 @@
Docker version 18.09.1, build 4c52b90

29
biscd/biscd/__init__.py

@ -8,29 +8,14 @@ app = Flask(__name__)
Bootstrap(app) Bootstrap(app)
def read_config(): 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__) conf = confuse.Configuration('biscd', __name__)
valid = conf.get(config_template) try:
print('valid', valid) conf['config'].get()
print('dict', valid.__dict__) except confuse.NotFoundError:
print('message is', valid.config.message) raise ValueError("Failed to open any configfile containing a 'config' object. " \
if False:#not conf.has_section('MISC'): "Please make sure the module directory contains a config_default.yaml, " \
raise ValueError("Failed to open any configfile containing a MISC section. \ f"or /etc/{__name__}/config.yaml exists")
Please make sure the script dir contains a config.yml, \
or /etc/{__name__}.conf exists")
return conf['config'] return conf['config']
config = read_config() config = read_config()

2
biscd/biscd/config_default.yaml

@ -1,4 +1,4 @@
config: confiag:
flask_development_server: flask_development_server:
# Options: production, development # Options: production, development
flask_env: development flask_env: development

Loading…
Cancel
Save