Update sparkline with current %

This commit is contained in:
nicolargo 2019-04-18 09:34:02 +02:00
parent a5b46a9db1
commit f68da86493
4 changed files with 15 additions and 7 deletions

View File

@ -13,11 +13,12 @@ If the per CPU mode is on (by clicking the ``1`` key):
.. image:: ../_static/quicklook-percpu.png
In the Curses/terminal interface, it is also possible to switch from bar to
sparkline using 'S' hot key or --sparkline command line option. Please be
aware that sparklines use the Glances history and will not be available
if the history is disabled from the command line.
sparkline using 'S' hot key or --sparkline command line option (nned the
sparklines Python lib on your system). Please be aware that sparklines use
the Glances history and will not be available if the history is disabled from
the command line.
.. image:: ../_static/sparkline.png
.. image:: ../_static/sparkline.png
.. note::
Limit values can be overwritten in the configuration file under

View File

@ -27,13 +27,13 @@ sparklines_module = True
try:
from sparklines import sparklines
except ImportError as e:
logger.debug("Sparklines module not found ({})".format(e))
logger.warning("Sparklines module not found ({})".format(e))
sparklines_module = False
try:
'\xe2\x96\x81'.decode('utf-8')
except ImportError as e:
logger.debug("UTF-8 for sparklines module not available".format(e))
logger.warning("UTF-8 is mandatory for sparklines ({})".format(e))
sparklines_module = False
@ -88,4 +88,9 @@ class Sparkline(object):
def __str__(self):
"""Return the sparkline."""
return self.get()
ret = self.get()
if self.__with_text:
percents_without_none = [x for x in self.percents if x is not None]
if len(percents_without_none) > 0:
ret = '{}{:5.1f}%'.format(ret, percents_without_none[-1])
return ret

View File

@ -21,6 +21,7 @@ pystache
pyzmq
requests
scandir; python_version < "3.5"
sparklines
statsd
wifi
zeroconf==0.19.1; python_version < "3.0"

View File

@ -67,6 +67,7 @@ def get_install_extras_require():
'raid': ['pymdstat'],
'smart': ['pySMART.smartx'],
'snmp': ['pysnmp'],
'sparklines': ['sparklines'],
'web': ['bottle', 'requests'],
'wifi': ['wifi']
}