Merge pull request #625 from martindoublem/martin-development

Improved three modules in showing more compacted info with new parameters
This commit is contained in:
tobi-wan-kenobi 2020-05-08 16:08:54 +02:00 committed by GitHub
commit fde51b3f79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -26,7 +26,7 @@ class Module(core.module.Module):
state = [] state = []
if self.__info == "OK - 0": if self.__info == "OK - 0":
state.append("warning") state.append("warning")
elif self.__info in ["n/a", "daemon off"]: elif self.__info in ["n/a", "Off"]:
state.append("critical") state.append("critical")
return state return state
@ -38,7 +38,7 @@ class Module(core.module.Module):
len(cli.containers.list(filters={"status": "running"})) len(cli.containers.list(filters={"status": "running"}))
) )
except ConnectionError: except ConnectionError:
self.__info = "daemon off" self.__info = "Off"
except Exception: except Exception:
self.__info = "n/a" self.__info = "n/a"
return self.__info return self.__info

View file

@ -7,7 +7,8 @@
Parameters: Parameters:
* smartstatus.display: how to display (defaults to 'combined', other choices: 'seperate' or 'singles') * smartstatus.display: how to display (defaults to 'combined', other choices: 'seperate' or 'singles')
* smartstauts.drives: in the case of singles which drives to display, separated comma list value, multiple accepted (defaults to 'sda', example:'sda,sdc') * smartstatus.drives: in the case of singles which drives to display, separated comma list value, multiple accepted (defaults to 'sda', example:'sda,sdc')
* smartstatus.shownames: boolean in the form of "True" or "False" to show the name of the drives in the form of sda, sbd, combined or none at all.
""" """
import os import os
@ -29,6 +30,7 @@ class Module(core.module.Module):
self.devices = self.list_devices() self.devices = self.list_devices()
self.display = self.parameter("display", "combined") self.display = self.parameter("display", "combined")
self.drives = self.parameter("drives", "sda") self.drives = self.parameter("drives", "sda")
self.show_names = self.parameter("show_names", "True")
self.widgets(self.create_widgets()) self.widgets(self.create_widgets())
def create_widgets(self): def create_widgets(self):
@ -63,7 +65,10 @@ class Module(core.module.Module):
def output(self, widget): def output(self, widget):
device = widget.get("device") device = widget.get("device")
assessment = widget.get("assessment") assessment = widget.get("assessment")
widget.full_text("{}: {}".format(device, assessment)) if self.show_names == "False":
widget.full_text("{}".format(assessment))
else:
widget.full_text("{}: {}".format(device, assessment))
def state(self, widget): def state(self, widget):
states = [] states = []

View file

@ -11,6 +11,7 @@ Parameters:
'auto' uses whatever redshift is configured to do 'auto' uses whatever redshift is configured to do
* redshift.lat : latitude if location is set to 'manual' * redshift.lat : latitude if location is set to 'manual'
* redshift.lon : longitude if location is set to 'manual' * redshift.lon : longitude if location is set to 'manual'
* redshift.transition_info: information about the transitions (x% day) defaults to True
""" """
import re import re
@ -74,6 +75,7 @@ class Module(core.module.Module):
super().__init__(config, theme, core.widget.Widget(self.text)) super().__init__(config, theme, core.widget.Widget(self.text))
self.__thread = None self.__thread = None
self.transition_info = self.parameter("transition_info", "True")
if self.parameter("location", "") == "ipinfo": if self.parameter("location", "") == "ipinfo":
# override lon/lat with ipinfo # override lon/lat with ipinfo
@ -91,7 +93,7 @@ class Module(core.module.Module):
def text(self, widget): def text(self, widget):
val = widget.get("temp", "n/a") val = widget.get("temp", "n/a")
transition = widget.get("transition", "") transition = widget.get("transition", "")
if transition: if transition and self.transition_info=="True":
val = "{} {}".format(val, transition) val = "{} {}".format(val, transition)
return val return val