|
|
|
@ -8,29 +8,14 @@ app = Flask(__name__)
@@ -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() |
|
|
|
|