display popup if error parsing config file

This commit is contained in:
sqlcoder 2010-02-20 10:27:58 +00:00
parent 0cafb75c59
commit ebf2205859
2 changed files with 16 additions and 3 deletions

View File

@ -481,12 +481,19 @@ class Config:
print "\nReading configuration file %s\n" % file
try:
doc = xml.dom.minidom.parse(file)
self.file_error = None
except:
log.error("Error parsing %s. See error log file." % (file))
traceback.print_exc(file=sys.stderr)
print "press enter to continue"
sys.stdin.readline()
sys.exit()
self.file_error = sys.exc_info()[1]
# we could add a parameter to decide whether to return or read a line and exit?
return
#print "press enter to continue"
#sys.stdin.readline()
#sys.exit()
#ExpatError: not well-formed (invalid token): line 511, column 4
#sys.exc_info = (<class 'xml.parsers.expat.ExpatError'>, ExpatError('not well-formed (invalid token): line 511,
# column 4',), <traceback object at 0x024503A0>)
self.doc = doc
self.supported_sites = {}

View File

@ -688,6 +688,12 @@ class fpdb:
def load_profile(self):
"""Loads profile from the provided path name."""
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
if self.config.file_error:
self.warning_box( "There is an error in your config file\n" + self.config.file
+ "\n\nError is: " + str(self.config.file_error)
, diatitle="CONFIG FILE ERROR" )
exit()
log = Configuration.get_logger("logging.conf", "fpdb", log_dir=self.config.dir_log)
print "Logfile is " + os.path.join(self.config.dir_log, self.config.log_file) + "\n"
if self.config.example_copy: