pingdom: add format
@@ -9,6 +9,7 @@ Configuration parameters:
app_key: create an APP KEY on pingdom first (default '')
cache_timeout: how often to refresh the check from pingdom (default 600)
checks: comma separated pindgom check names to display (default '')
+ format: display format for this module (default '{output}')
login: pingdom login (default '')
max_latency: maximal latency before coloring the output (default 500)
password: pingdom password (default '')
@@ -33,13 +34,15 @@ class Py3status:
app_key = ''
cache_timeout = 600
checks = ''
+ format = '{output}'
login = ''
max_latency = 500
password = ''
request_timeout = 15
def pingdom_checks(self):
- response = {'full_text': ''}
+ response = {'cached_until': self.py3.time_in(self.cache_timeout)}
+ out = None
# parse some configuration parameters
if not isinstance(self.checks, list):
@@ -57,22 +60,20 @@ class Py3status:
ck for ck in result['checks'] if ck['name'] in self.checks
]:
if check['status'] == 'up':
- response['full_text'] += '{}: {}ms, '.format(
+ out += '{}: {}ms, '.format(
check['name'],
check['lastresponsetime']
)
if check['lastresponsetime'] > self.max_latency:
- response.update(
- {'color': self.py3.COLOR_DEGRADED}
- )
+ response['color'] = self.py3.COLOR_DEGRADED
else:
- response['full_text'] += '{}: DOWN'.format(
+ response['color'] = self.py3.COLOR_BAD
+ out += '{}: DOWN'.format(
check['name'],
check['lastresponsetime']
)
- response.update({'color': self.py3.COLOR_BAD})
- response['full_text'] = response['full_text'].strip(', ')
- response['cached_until'] = self.py3.time_in(self.cache_timeout)
+ out = out.strip(', ')
+ response['full_text'] = self.py3.safe_format(self.format, {'output': out})
return response
