From 551bdbfe851297095d7fc7a52f88e36cef5a457a Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 7 Feb 2021 16:15:29 +0100 Subject: [PATCH] Correct an issue if section did not exist --- glances/config.py | 10 +++++----- glances/plugins/glances_diskio.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/glances/config.py b/glances/config.py index e131ad7e..7ab8cfd6 100644 --- a/glances/config.py +++ b/glances/config.py @@ -25,7 +25,7 @@ import multiprocessing from io import open import re -from glances.compat import ConfigParser, NoOptionError, system_exec +from glances.compat import ConfigParser, NoOptionError, NoSectionError, system_exec from glances.globals import BSD, LINUX, MACOS, SUNOS, WINDOWS from glances.logger import logger @@ -295,7 +295,7 @@ class Config(object): ret = default try: ret = self.parser.get(section, option) - except NoOptionError: + except (NoOptionError, NoSectionError): pass # Search a substring `foo` and replace it by the result of its exec @@ -312,19 +312,19 @@ class Config(object): """Get the int value of an option, if it exists.""" try: return self.parser.getint(section, option) - except NoOptionError: + except (NoOptionError, NoSectionError): return int(default) def get_float_value(self, section, option, default=0.0): """Get the float value of an option, if it exists.""" try: return self.parser.getfloat(section, option) - except NoOptionError: + except (NoOptionError, NoSectionError): return float(default) def get_bool_value(self, section, option, default=True): """Get the bool value of an option, if it exists.""" try: return self.parser.getboolean(section, option) - except NoOptionError: + except (NoOptionError, NoSectionError): return bool(default) diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py index 9ac1e4ec..952fa870 100644 --- a/glances/plugins/glances_diskio.py +++ b/glances/plugins/glances_diskio.py @@ -54,7 +54,7 @@ class Plugin(GlancesPlugin): self.display_curse = True # Hide stats if it has never been != 0 self.hide_zero = config.get_bool_value( - self.plugin_name, 'hide_zero', default=False) + self.plugin_name + 'XXX', 'hide_zero', default=False) self.hide_zero_fields = ['read_bytes', 'write_bytes'] def get_key(self):