Commit 81ac4947 authored by Valentin Reis's avatar Valentin Reis

Logging an error in case of malformed machine_info.

Related to #22
parent e626053c
Pipeline #4599 passed with stages
in 55 seconds
......@@ -91,7 +91,13 @@ class Controller(object):
def planify(self, target, machineinfo):
"""Plan the next action for the control loop."""
total_power = machineinfo['energy']['power']['total']
except TypeError:
logging.error("\"machineinfo\" malformed. Can not run "
"control loop.")
return (None, None)
direction = None
if total_power < target:
direction = 'i'
......@@ -154,7 +154,12 @@ class Daemon(object):
def do_sensor(self):
self.machine_info = self.sensor_manager.do_update()"current state: %r", self.machine_info)
total_power = self.machine_info['energy']['power']['total']
except TypeError:
logger.error("power sensor format malformed, "
"can not report power upstream.")
msg = {'api': 'up_pub',
'type': 'power',
'total': total_power,
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment