Correct encoding issue with AMP sustemd and Python 3.5

This commit is contained in:
nicolargo 2016-12-27 21:45:11 +01:00
parent 0ba5b95ff1
commit 32eff4d079
3 changed files with 5 additions and 3 deletions

View File

@ -48,7 +48,7 @@ systemctl_cmd=/usr/bin/systemctl --plain
from subprocess import check_output
from glances.logger import logger
from glances.compat import iteritems
from glances.compat import iteritems, to_ascii
from glances.amps.glances_amp import GlancesAmp
@ -76,7 +76,7 @@ class Amp(GlancesAmp):
else:
status = {}
# For each line
for r in res.split('\n')[1:-8]:
for r in to_ascii(res).split('\n')[1:-8]:
# Split per space .*
l = r.split()
if len(l) > 3:

View File

@ -106,6 +106,8 @@ else:
def to_ascii(s):
"""Convert the unicode 's' to a ASCII string
Usefull to remove accent (diacritics)"""
if isinstance(s, binary_type):
return s
return unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
def listitems(d):