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

This commit is contained in:
nicolargo 2017-09-30 09:48:15 +02:00
parent e3f2b1bbe2
commit fd5e5e863d
2 changed files with 10 additions and 6 deletions

4
NEWS
View File

@ -9,6 +9,10 @@ Enhancements and new features:
* ...
Bugs corrected:
* Failed to connect to bus: No such file or directory #1156
==============================================================================
Glances Version 2
==============================================================================

View File

@ -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):