Use the one_line method

This commit is contained in:
Nicolargo 2016-04-25 13:42:19 +02:00
parent 37c2d75772
commit 84a40237db
2 changed files with 9 additions and 1 deletions

View File

@ -130,6 +130,14 @@ class GlancesAmp(object):
"""Return refresh time in seconds for the current application monitoring process."""
return self.get('refresh')
def one_line(self):
"""Return True|False if the AMP shoukd be displayed in oneline (one_lineline=true|false)."""
ret = self.get('one_line')
if ret is None:
return False
else:
return ret.lower().startswith('true')
def time_until_refresh(self):
"""Return time in seconds until refresh."""
return self.timer.get()

View File

@ -81,7 +81,7 @@ class Amp(GlancesAmp):
req = requests.get(self.get('status_url'))
if req.ok:
# u'Active connections: 1 \nserver accepts handled requests\n 1 1 1 \nReading: 0 Writing: 1 Waiting: 0 \n'
if self.get('one_line') is not None and self.get('one_line').lower() == 'true':
if self.one_line():
self.set_result(req.text.replace('\n', ''))
else:
self.set_result(req.text)