[modules/nic] Do not fail if iwgetid is not available

Instead of throwing an error, simply return an empty SSID. Also, for
these cases, make sure the module doesn't output multiple whitespaces as
the end.

fixes #248
This commit is contained in:
Tobias Witek 2018-04-14 05:33:35 +02:00
parent d32f452cdd
commit f3dfd1d577

View file

@ -93,7 +93,8 @@ class Module(bumblebee.engine.Module):
if not widget: if not widget:
widget = bumblebee.output.Widget(name=intf) widget = bumblebee.output.Widget(name=intf)
widgets.append(widget) widgets.append(widget)
widget.full_text(self._format.format(ip=", ".join(addr),intf=intf,state=state,ssid=self.get_ssid(intf))) # join/split is used to get rid of multiple whitespaces (in case SSID is not available, for instance
widget.full_text(" ".join(self._format.format(ip=", ".join(addr),intf=intf,state=state,ssid=self.get_ssid(intf)).split()))
widget.set("intf", intf) widget.set("intf", intf)
widget.set("state", state) widget.set("state", state)
widget.set("visited", True) widget.set("visited", True)
@ -106,7 +107,7 @@ class Module(bumblebee.engine.Module):
if self._iswlan(intf): if self._iswlan(intf):
try: try:
return subprocess.check_output(["iwgetid","-r",intf]).strip().decode('utf-8') return subprocess.check_output(["iwgetid","-r",intf]).strip().decode('utf-8')
except subprocess.CalledProcessError: except:
return "" return ""
return "" return ""