[modules/sensors2] Fix runtime errors
This commit is contained in:
parent
908ef67109
commit
d5820160dc
4 changed files with 6 additions and 8 deletions
|
@ -68,7 +68,7 @@ if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
output = core.output.i3()
|
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.draw('start')
|
||||||
output.update()
|
output.update()
|
||||||
output.draw('statusline')
|
output.draw('statusline')
|
||||||
|
|
|
@ -26,7 +26,7 @@ def load(module_name, config=None):
|
||||||
if not error:
|
if not error:
|
||||||
error = 'No such module'
|
error = 'No such module'
|
||||||
log.fatal('failed to import {}: {}'.format(module_name, error))
|
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):
|
class Module(core.input.Object):
|
||||||
def __init__(self, config=None, widgets=[]):
|
def __init__(self, config=None, widgets=[]):
|
||||||
|
@ -56,7 +56,7 @@ class Module(core.input.Object):
|
||||||
try:
|
try:
|
||||||
self.update()
|
self.update()
|
||||||
except Exception as e:
|
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._widgets = [module.widget()]
|
||||||
self.update = module.update
|
self.update = module.update
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class Module(core.input.Object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Error(Module):
|
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))
|
super().__init__(config, core.widget.Widget(self.full_text))
|
||||||
self._module = module
|
self._module = module
|
||||||
self._error = error
|
self._error = error
|
||||||
|
|
|
@ -93,7 +93,7 @@ class i3(object):
|
||||||
def widgets(self, module):
|
def widgets(self, module):
|
||||||
widgets = []
|
widgets = []
|
||||||
for widget in 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']):
|
if not any(state in widget.state() for state in [ 'warning', 'critical']):
|
||||||
continue
|
continue
|
||||||
widgets += self.__separator(module, widget)
|
widgets += self.__separator(module, widget)
|
||||||
|
|
|
@ -27,11 +27,9 @@ class Module(core.module.Module):
|
||||||
|
|
||||||
self.__chip = self.parameter('chip', '')
|
self.__chip = self.parameter('chip', '')
|
||||||
self.__data = {}
|
self.__data = {}
|
||||||
self.__update()
|
|
||||||
|
|
||||||
self.widgets(self.__create_widgets())
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
self.widgets(self.__create_widgets())
|
||||||
self.__update()
|
self.__update()
|
||||||
for widget in self.widgets():
|
for widget in self.widgets():
|
||||||
self.__update_widget(widget)
|
self.__update_widget(widget)
|
||||||
|
|
Loading…
Reference in a new issue