mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-19 23:31:52 +03:00
Correct an issue if section did not exist
This commit is contained in:
parent
7bcf1f3bae
commit
551bdbfe85
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user