Private GIT

Skip to content
Snippets Groups Projects
Commit 037a9fba authored by Sean Rees's avatar Sean Rees
Browse files

Fix a startup ordering bug that prevented --create_device_cache from working

parent d2055be8
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,8 @@ class DeviceWrapper:
return self.libdyson.is_connected
def connect(self, host: str):
"""Connect to the device and start the environmental monitoring timer."""
"""Connect to the device and start the environmental monitoring
timer."""
self.libdyson.connect(host)
self._refresh_timer()
......@@ -208,18 +209,23 @@ def main(argv):
logging.exception('Could not load configuration: %s', args.config)
sys.exit(-1)
devices = cfg.devices
if len(devices) == 0:
logging.fatal(
'No devices configured; please re-run this program with --create_device_cache.')
sys.exit(-2)
if args.create_device_cache:
if not cfg.dyson_credentials:
logging.error('DysonLink credentials not found in %s, cannot generate device cache',
args.config)
sys.exit(-1)
logging.info(
'--create_device_cache supplied; breaking out to perform this.')
account.generate_device_cache(cfg.dyson_credentials, args.config)
sys.exit(0)
devices = cfg.devices
if len(devices) == 0:
logging.fatal(
'No devices configured; please re-run this program with --create_device_cache.')
sys.exit(-2)
prometheus_client.start_http_server(args.port)
ConnectionManager(metrics.Metrics().update, devices, cfg.hosts)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment