Manage unicode decode error on Windows OS

This commit is contained in:
Nicolargo 2014-04-26 15:52:59 +02:00
parent cb3b3de783
commit 7ce0383eae
2 changed files with 10 additions and 2 deletions

View File

@ -46,7 +46,12 @@ class glancesGrabFs:
# Grab the stats using the PsUtil disk_partitions
# If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys)
# and ignore all others (e.g. memory partitions such as /dev/shm)
fs_stat = psutil.disk_partitions(all=False)
try:
fs_stat = psutil.disk_partitions(all=False)
except UnicodeDecodeError:
return []
# Loop over fs
for fs in range(len(fs_stat)):
fs_current = {}
fs_current['device_name'] = fs_stat[fs].device

View File

@ -57,7 +57,10 @@ class Plugin(GlancesPlugin):
"""
# Grab network interface stat using the PsUtil net_io_counter method
netiocounters = psutil.net_io_counters(pernic=True)
try:
netiocounters = psutil.net_io_counters(pernic=True)
except UnicodeDecodeError:
return []
# Previous network interface stats are stored in the network_old variable
network = []