From d5820160dce1ad822bb4fa30189bf21a318daee0 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 28 Mar 2020 13:44:45 +0100 Subject: [PATCH] [modules/sensors2] Fix runtime errors --- bumblebee-status | 2 +- core/module.py | 6 +++--- core/output.py | 2 +- modules/core/sensors2.py | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bumblebee-status b/bumblebee-status index 3e11ea2..c3541c6 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -68,7 +68,7 @@ if __name__ == "__main__": main() except Exception as e: output = core.output.i3() - output.modules(core.module.Error(None, 'main', e)) + output.modules(core.module.Error(module='main', error=e)) output.draw('start') output.update() output.draw('statusline') diff --git a/core/module.py b/core/module.py index 4e34b2b..a2c0f3b 100644 --- a/core/module.py +++ b/core/module.py @@ -26,7 +26,7 @@ def load(module_name, config=None): if not error: error = 'No such module' log.fatal('failed to import {}: {}'.format(module_name, error)) - return Error(config, module_name, error) + return Error(config=config, module=module_name, error=error) class Module(core.input.Object): def __init__(self, config=None, widgets=[]): @@ -56,7 +56,7 @@ class Module(core.input.Object): try: self.update() except Exception as e: - module = Error(self._config, 'error', str(e)) + module = Error(config=self._config, module='error', error=str(e)) self._widgets = [module.widget()] self.update = module.update @@ -89,7 +89,7 @@ class Module(core.input.Object): return None class Error(Module): - def __init__(self, config, module, error): + def __init__(self, module, error, config=core.config.Config([])): super().__init__(config, core.widget.Widget(self.full_text)) self._module = module self._error = error diff --git a/core/output.py b/core/output.py index be0dd6a..927085b 100644 --- a/core/output.py +++ b/core/output.py @@ -93,7 +93,7 @@ class i3(object): def widgets(self, module): widgets = [] for widget in module.widgets(): - if self._config.autohide(widget.module().name()): + if widget.module() and self._config.autohide(widget.module().name()): if not any(state in widget.state() for state in [ 'warning', 'critical']): continue widgets += self.__separator(module, widget) diff --git a/modules/core/sensors2.py b/modules/core/sensors2.py index 8523bdd..1726dae 100644 --- a/modules/core/sensors2.py +++ b/modules/core/sensors2.py @@ -27,11 +27,9 @@ class Module(core.module.Module): self.__chip = self.parameter('chip', '') self.__data = {} - self.__update() - - self.widgets(self.__create_widgets()) def update(self): + self.widgets(self.__create_widgets()) self.__update() for widget in self.widgets(): self.__update_widget(widget)