Correct bug when no batterie is available

pull/416/head
Nicolas Hennion 2014-08-26 15:46:29 +02:00
parent c21f7e3fb8
commit d617e95aaf
2 changed files with 21 additions and 19 deletions

View File

@ -20,7 +20,7 @@
"""Init the Glances software."""
__appname__ = 'glances'
__version__ = '2.1_RC4'
__version__ = '2.1_RC5'
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
__license__ = 'LGPL'

View File

@ -27,7 +27,7 @@ except ImportError:
pass
# Import Glances lib
from glances.core.glances_globals import is_py3
from glances.core.glances_globals import is_py3, logger
from glances.plugins.glances_batpercent import Plugin as BatPercentPlugin
from glances.plugins.glances_hddtemp import Plugin as HddTempPlugin
from glances.plugins.glances_plugin import GlancesPlugin
@ -134,23 +134,25 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
for item in self.stats:
# New line
ret.append(self.curse_new_line())
# Alias for the lable name ?
label = self.has_alias(item['label'].lower())
if label is None:
label = item['label']
label = label[:18]
msg = '{0:18}'.format(label)
ret.append(self.curse_add_line(msg))
msg = '{0:>5}'.format(item['value'])
if item['type'] == 'battery':
try:
ret.append(self.curse_add_line(msg, self.get_alert(100 - item['value'], header=item['type'])))
except TypeError:
pass
else:
ret.append(self.curse_add_line(msg, self.get_alert(item['value'], header=item['type'])))
if item['value'] is not None and item['value'] != []:
logger.debug(item['value'])
# New line
ret.append(self.curse_new_line())
# Alias for the lable name ?
label = self.has_alias(item['label'].lower())
if label is None:
label = item['label']
label = label[:18]
msg = '{0:18}'.format(label)
ret.append(self.curse_add_line(msg))
msg = '{0:>5}'.format(item['value'])
if item['type'] == 'battery':
try:
ret.append(self.curse_add_line(msg, self.get_alert(100 - item['value'], header=item['type'])))
except TypeError:
pass
else:
ret.append(self.curse_add_line(msg, self.get_alert(item['value'], header=item['type'])))
return ret