[modules/battery] Fix syntax error

see #221
This commit is contained in:
Tobias Witek 2018-01-11 20:22:21 +01:00
parent bbfb6fc095
commit f236c24b92
3 changed files with 13 additions and 3 deletions

View file

@ -40,6 +40,7 @@ class Module(object):
self.id = self.name self.id = self.name
self._next = int(time.time()) self._next = int(time.time())
self._default_interval = 0 self._default_interval = 0
self.success = True
self._configFile = None self._configFile = None
for cfg in [os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf")]: for cfg in [os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf")]:
@ -80,7 +81,12 @@ class Module(object):
def update_wrapper(self, widgets): def update_wrapper(self, widgets):
if self._next > int(time.time()): if self._next > int(time.time()):
return return
self.update(self._widgets) try:
self.update(self._widgets)
self.success = True
except Exception as e:
log.error("failed to update module {}: {}".format(self.name, str(e)))
self.success = False
self._next += int(self.parameter("interval", self._default_interval))*60 self._next += int(self.parameter("interval", self._default_interval))*60
def interval(self, intvl): def interval(self, intvl):

View file

@ -105,8 +105,9 @@ class Module(bumblebee.engine.Module):
state.append("AC") state.append("AC")
else: else:
charge = "" charge = ""
with open("{}/status".format(widget.name)) as f: try:
charge = f.read().strip() with open("{}/status".format(widget.name)) as f:
charge = f.read().strip()
except IOError: except IOError:
pass pass
if charge == "Discharging": if charge == "Discharging":

View file

@ -17,6 +17,9 @@ class Module(bumblebee.engine.Module):
) )
self._text = self.parameter("text", "") self._text = self.parameter("text", "")
def update(self, widgets):
raise Exception("test")
def text(self, widget): def text(self, widget):
return self._text return self._text