From 86c37fa5b1c2a9f37b50dc19f0592102a137b496 Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sat, 8 Jun 2024 10:06:39 +0200 Subject: [PATCH] Remove unused settings. --- conf.yml-example | 6 +----- thermostat.py | 15 ++++----------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/conf.yml-example b/conf.yml-example index bed58f5..58197b2 100644 --- a/conf.yml-example +++ b/conf.yml-example @@ -1,10 +1,6 @@ api_key: "FIXME" -flask_settings_dev: - DEBUG: True - -flask_settings_prod: - DEBUG: False +debug: False targets: - target_awake_temperature diff --git a/thermostat.py b/thermostat.py index cbc09e5..ddfbb7c 100755 --- a/thermostat.py +++ b/thermostat.py @@ -44,17 +44,12 @@ authorizations = { with open('./conf.yml') as conf: yaml_conf = yaml.safe_load(conf) - flask_settings = yaml_conf.get("flask_settings") + debug = yaml_conf.get("debug") api_key = yaml_conf.get("api_key") - if os.environ['FLASK_ENV'] == 'development': - flask_settings_env = yaml_conf.get("flask_settings_dev") - logging.getLogger().setLevel(logging.DEBUG) - elif os.environ['FLASK_ENV'] == 'production': - flask_settings_env = yaml_conf.get("flask_settings_prod") - logging.getLogger().setLevel(logging.INFO) + if debug: + logging.getLogger().setLevel(logging.DEBUG) else: - logging.error("FLASK_ENV must be set to development or production.") - sys.exit(1) + logging.getLogger().setLevel(logging.INFO) targets = yaml_conf.get("targets") modes = yaml_conf.get("modes") http_port = yaml_conf.get("http_port") @@ -175,8 +170,6 @@ signal.signal(signal.SIGTERM,handler) signal.signal(signal.SIGINT,handler) app = Flask(__name__) -app.config.from_mapping(flask_settings) -app.config.from_mapping(flask_settings_env) api = Api(app, version='1.0', title='Thermostat and load shedder', description='API to read and set thermostat.', authorizations=authorizations) ns_thermostat = api.namespace('thermostat/', description='Thermostat API')