diff --git a/reports.py b/reports.py index d43b20b..13afa94 100644 --- a/reports.py +++ b/reports.py @@ -21,24 +21,24 @@ def __init__(self, config, sg_timer, sg_notify): self.sg_notify = sg_notify # send startup report - if self.config.startup: + if 'startup' in self.config: self.sg_notify.notify(self.config.startup, 'Stargate is now running', 'Stargate startup') # register for shutdown events - sg_signal.add_exit_listener(self.on_exit) + if 'shutdown' in self.config: + sg_signal.add_exit_listener(self.on_exit) # register for logger.exception - sg_signal.add_exception_listener(self.on_exception) + if 'exception' in self.config: + sg_signal.add_exception_listener(self.on_exception) # install timers for interval summaries # TODO... def on_exception(self): - if self.config.exception: - report = traceback.format_exc(); - self.sg_notify.notify(self.config.exception, report, 'Stargate exception report') + report = traceback.format_exc(); + self.sg_notify.notify(self.config.exception, report, 'Stargate exception report') def on_exit(self): # send shutdown report - if self.config.shutdown: - self.sg_notify.notify(self.config.shutdown, 'Stargate has stopped', 'Stargate shutdown') + self.sg_notify.notify(self.config.shutdown, 'Stargate has stopped', 'Stargate shutdown') diff --git a/sg_house.py b/sg_house.py index 2bcdbc7..f90e5d6 100644 --- a/sg_house.py +++ b/sg_house.py @@ -253,8 +253,9 @@ def __init__(self, config): self.notify = notify.SgNotify(config.notifications) # SgNotify instance self.persist = persistence.SgPersistence(config.database, # SgPersistence instance self.events, self.timer) - self.reports = reports.SgReporter(config.reporting, # SgReporter instance - self.timer, self.notify) + if config.get('reporting'): + self.reports = reports.SgReporter(config.reporting, # SgReporter instance + self.timer, self.notify) self.watchdog = connections.SgWatchdog() # SgWatchdog instance self.areas_by_name = {} # Map from area name to area object self.devices_by_id = {} # Map from device id to device object