Merge branch 'refactor_curses' into develop

This commit is contained in:
nicolargo 2016-11-12 10:25:06 +01:00
commit de369be5b3
2 changed files with 41 additions and 19 deletions

View File

@ -241,6 +241,13 @@ class Config(object):
except NoOptionError: except NoOptionError:
return default return default
def get_int_value(self, section, option, default=0):
"""Get the int value of an option, if it exists."""
try:
return self.parser.getint(section, option)
except NoOptionError:
return int(default)
def get_float_value(self, section, option, default=0.0): def get_float_value(self, section, option, default=0.0):
"""Get the float value of an option, if it exists.""" """Get the float value of an option, if it exists."""
try: try:

View File

@ -113,7 +113,6 @@ class _GlancesCurses(object):
# Load the 'outputs' section of the configuration file # Load the 'outputs' section of the configuration file
# - Init the theme (default is black) # - Init the theme (default is black)
self.theme = {'name': 'black'} self.theme = {'name': 'black'}
self.load_config(self.config)
# Init cursor # Init cursor
self._init_cursor() self._init_cursor()
@ -382,32 +381,48 @@ class _GlancesCurses(object):
glances_processes.enable_extended() glances_processes.enable_extended()
if self.args.disable_top: if self.args.disable_top:
self.args.disable_quicklook = True self.disable_top()
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_memswap = True
self.args.disable_load = True
else: else:
self.args.disable_quicklook = False self.enable_top()
self.args.disable_cpu = False
self.args.disable_mem = False
self.args.disable_memswap = False
self.args.disable_load = False
if self.args.full_quicklook: if self.args.full_quicklook:
self.args.disable_quicklook = False self.enable_fullquicklook()
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_memswap = True
else: else:
self.args.disable_quicklook = False self.disable_fullquicklook()
self.args.disable_cpu = False
self.args.disable_mem = False
self.args.disable_memswap = False
# Return the key code # Return the key code
return self.pressedkey return self.pressedkey
def disable_top(self):
"""Disable the top panel"""
self.args.disable_quicklook = True
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_memswap = True
self.args.disable_load = True
def enable_top(self):
"""Enable the top panel"""
self.args.disable_quicklook = False
self.args.disable_cpu = False
self.args.disable_mem = False
self.args.disable_memswap = False
self.args.disable_load = False
def disable_fullquicklook(self):
"""Disable the full quicklook mode"""
self.args.disable_quicklook = False
self.args.disable_cpu = False
self.args.disable_mem = False
self.args.disable_memswap = False
def enable_fullquicklook(self):
"""Disable the full quicklook mode"""
self.args.disable_quicklook = False
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_memswap = True
def end(self): def end(self):
"""Shutdown the curses window.""" """Shutdown the curses window."""
if hasattr(curses, 'echo'): if hasattr(curses, 'echo'):