use json instead of ini: less readable, easier to work with
This commit is contained in:
parent
f5c49008ec
commit
5e17aca8e2
11 changed files with 108 additions and 82 deletions
|
@ -4,15 +4,13 @@ import plugins
|
|||
|
||||
|
||||
class PluginThread(plugins.PluginThreadCommon):
|
||||
def __init__(self, section, config):
|
||||
super(PluginThread, self).__init__(section, config)
|
||||
self.hosts = config.get(section, 'hosts').split(',')
|
||||
self.title = config.get(section, 'title')
|
||||
self.timeout = config.get(section, 'timeout', fallback='150')
|
||||
def __init__(self, config):
|
||||
defaults = {'hosts': list(), 'title': 'PING', 'timeout': 150}
|
||||
super(PluginThread, self).__init__(config, defaults)
|
||||
self.format_status('n/a')
|
||||
|
||||
def format_status(self, state):
|
||||
self.status['full_text'] = self.title + ': ' + state
|
||||
self.status['full_text'] = self.conf['title'] + ': ' + state
|
||||
if state == 'on':
|
||||
self.status['urgent'] = False
|
||||
self.hide = True
|
||||
|
@ -20,9 +18,10 @@ class PluginThread(plugins.PluginThreadCommon):
|
|||
self.status['urgent'] = True
|
||||
|
||||
def main(self):
|
||||
random.shuffle(self.hosts)
|
||||
for host in self.hosts:
|
||||
fping = 'fping -qc1t' + self.timeout + ' ' + host + ' &>/dev/null'
|
||||
random.shuffle(self.conf['hosts'])
|
||||
for host in self.conf['hosts']:
|
||||
fping = 'fping -qc1t' + str(self.conf['timeout'])\
|
||||
+ ' ' + host + ' &>/dev/null'
|
||||
response = os.system(fping)
|
||||
if response == 0:
|
||||
self.format_status('on')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue