diff options
author | nicolargo <nicolas@nicolargo.com> | 2021-02-07 16:15:29 +0100 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2021-02-07 16:15:29 +0100 |
commit | aea9942361b15e6c071bc05a6b07c13053e4086a (patch) | |
tree | cd289f31ff2c36bd01d366892d0f24b994fe6489 | |
parent | 040528aab2102226cbd225acd04c51c0f8e7df32 (diff) |
Correct an issue if section did not existv3.1.6.2
-rw-r--r-- | glances/config.py | 10 | ||||
-rw-r--r-- | 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): |