提交 fd5e5e86 编写于 作者: N nicolargo

Failed to connect to bus: No such file or directory #1156

上级 e3f2b1bb
......@@ -9,6 +9,10 @@ Enhancements and new features:
* ...
Bugs corrected:
* Failed to connect to bus: No such file or directory #1156
==============================================================================
Glances Version 2
==============================================================================
......
......@@ -45,7 +45,7 @@ one_line=true
systemctl_cmd=/usr/bin/systemctl --plain
"""
from subprocess import check_output
from subprocess import check_output, CalledProcessError
from glances.logger import logger
from glances.compat import iteritems, to_ascii
......@@ -71,21 +71,21 @@ class Amp(GlancesAmp):
logger.debug('{}: Update stats using systemctl {}'.format(self.NAME, self.get('systemctl_cmd')))
try:
res = check_output(self.get('systemctl_cmd').split())
except OSError as e:
except (OSError, CalledProcessError) as e:
logger.debug('{}: Error while executing systemctl ({})'.format(self.NAME, e))
else:
status = {}
# For each line
for r in to_ascii(res).split('\n')[1:-8]:
# Split per space .*
l = r.split()
if len(l) > 3:
column = r.split()
if len(column) > 3:
# load column
for c in range(1, 3):
try:
status[l[c]] += 1
status[column[c]] += 1
except KeyError:
status[l[c]] = 1
status[column[c]] = 1
# Build the output (string) message
output = 'Services\n'
for k, v in iteritems(status):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册