From 7ce0383eae384957eb97032179d6da9f51c0f230 Mon Sep 17 00:00:00 2001 From: Nicolargo Date: Sat, 26 Apr 2014 15:52:59 +0200 Subject: [PATCH] Manage unicode decode error on Windows OS --- glances/plugins/glances_fs.py | 7 ++++++- glances/plugins/glances_network.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/glances/plugins/glances_fs.py b/glances/plugins/glances_fs.py index d4f07cc8..c3d20321 100644 --- a/glances/plugins/glances_fs.py +++ b/glances/plugins/glances_fs.py @@ -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 diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py index 7e9f7e8e..1c9e4ca3 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -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 = []