Don't spit out multiple identical errors when failing to open a config file

This commit is contained in:
Chris Jones 2010-04-05 23:06:30 +01:00
parent d1cd3809dc
commit 21885c424f
1 changed files with 8 additions and 1 deletions

View File

@ -385,6 +385,7 @@ class Config(object):
class ConfigBase(Borg): class ConfigBase(Borg):
"""Class to provide access to our user configuration""" """Class to provide access to our user configuration"""
loaded = None loaded = None
whined = None
sections = None sections = None
global_config = None global_config = None
profiles = None profiles = None
@ -405,6 +406,8 @@ class ConfigBase(Borg):
"""Set up our borg environment""" """Set up our borg environment"""
if self.loaded is None: if self.loaded is None:
self.loaded = False self.loaded = False
if self.whined is None:
self.whined = False
if self.sections is None: if self.sections is None:
self.sections = ['global_config', 'keybindings', 'profiles', self.sections = ['global_config', 'keybindings', 'profiles',
'layouts', 'plugins'] 'layouts', 'plugins']
@ -500,8 +503,12 @@ class ConfigBase(Borg):
try: try:
configfile = open(filename, 'r') configfile = open(filename, 'r')
except Exception, ex: except Exception, ex:
if not self.whined:
err('ConfigBase::load: Unable to open %s (%s)' % (filename, ex)) err('ConfigBase::load: Unable to open %s (%s)' % (filename, ex))
self.whined = True
return return
# If we have successfully loaded a config, allow future whining
self.whined = False
try: try:
configspec = self.defaults_to_configspec() configspec = self.defaults_to_configspec()