Add `short` param for system_load segment
Testing included
This commit is contained in:
parent
77322aeaf2
commit
e3369f200f
|
@ -13,7 +13,8 @@ from powerline.segments import with_docstring
|
|||
cpu_count = None
|
||||
|
||||
|
||||
def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2, track_cpu_count=False):
|
||||
def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2,
|
||||
track_cpu_count=False, short=False):
|
||||
'''Return system load average.
|
||||
|
||||
Highlights using ``system_load_good``, ``system_load_bad`` and
|
||||
|
@ -35,6 +36,8 @@ def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2, track
|
|||
:param bool track_cpu_count:
|
||||
if True powerline will continuously poll the system to detect changes
|
||||
in the number of CPUs.
|
||||
:param bool short:
|
||||
if True only the sys load over last 1 minute will be displayed.
|
||||
|
||||
Divider highlight group used: ``background:divider``.
|
||||
|
||||
|
@ -61,6 +64,10 @@ def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2, track
|
|||
'divider_highlight_group': 'background:divider',
|
||||
'gradient_level': gradient_level,
|
||||
})
|
||||
|
||||
if short:
|
||||
return ret
|
||||
|
||||
ret[0]['contents'] += ' '
|
||||
ret[1]['contents'] += ' '
|
||||
return ret
|
||||
|
|
|
@ -811,6 +811,12 @@ class TestSys(TestCommon):
|
|||
{'contents': '4 ', 'highlight_groups': ['system_load_gradient', 'system_load'], 'divider_highlight_group': 'background:divider', 'gradient_level': 100},
|
||||
{'contents': '2', 'highlight_groups': ['system_load_gradient', 'system_load'], 'divider_highlight_group': 'background:divider', 'gradient_level': 75.0}
|
||||
])
|
||||
self.assertEqual(self.module.system_load(pl=pl, short=True), [
|
||||
{'contents': '7.5', 'highlight_groups': ['system_load_gradient', 'system_load'], 'divider_highlight_group': 'background:divider', 'gradient_level': 100},
|
||||
])
|
||||
self.assertEqual(self.module.system_load(pl=pl, format='{avg:.0f}', threshold_good=0, threshold_bad=1, short=True), [
|
||||
{'contents': '8', 'highlight_groups': ['system_load_gradient', 'system_load'], 'divider_highlight_group': 'background:divider', 'gradient_level': 100},
|
||||
])
|
||||
|
||||
def test_cpu_load_percent(self):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue