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,31 +381,47 @@ class _GlancesCurses(object):
glances_processes.enable_extended() glances_processes.enable_extended()
if self.args.disable_top: if self.args.disable_top:
self.disable_top()
else:
self.enable_top()
if self.args.full_quicklook:
self.enable_fullquicklook()
else:
self.disable_fullquicklook()
# Return the key code
return self.pressedkey
def disable_top(self):
"""Disable the top panel"""
self.args.disable_quicklook = True self.args.disable_quicklook = True
self.args.disable_cpu = True self.args.disable_cpu = True
self.args.disable_mem = True self.args.disable_mem = True
self.args.disable_memswap = True self.args.disable_memswap = True
self.args.disable_load = True self.args.disable_load = True
else:
def enable_top(self):
"""Enable the top panel"""
self.args.disable_quicklook = False self.args.disable_quicklook = False
self.args.disable_cpu = False self.args.disable_cpu = False
self.args.disable_mem = False self.args.disable_mem = False
self.args.disable_memswap = False self.args.disable_memswap = False
self.args.disable_load = False self.args.disable_load = False
if self.args.full_quicklook: def disable_fullquicklook(self):
self.args.disable_quicklook = False """Disable the full quicklook mode"""
self.args.disable_cpu = True
self.args.disable_mem = True
self.args.disable_memswap = True
else:
self.args.disable_quicklook = False self.args.disable_quicklook = False
self.args.disable_cpu = False self.args.disable_cpu = False
self.args.disable_mem = False self.args.disable_mem = False
self.args.disable_memswap = False self.args.disable_memswap = False
# Return the key code def enable_fullquicklook(self):
return self.pressedkey """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."""