提交 d617e95a 编写于 作者: N Nicolas Hennion

Correct bug when no batterie is available

上级 c21f7e3f
......@@ -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'
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册