From ebf2205859ef4a0ea55cad0ab1cbaeca04c8e2c0 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 20 Feb 2010 10:27:58 +0000 Subject: [PATCH] display popup if error parsing config file --- pyfpdb/Configuration.py | 13 ++++++++++--- pyfpdb/fpdb.py | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index f7694e90..3d506735 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -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 = (, ExpatError('not well-formed (invalid token): line 511, +# column 4',), ) self.doc = doc self.supported_sites = {} diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 55b19a3b..29f5ff6a 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -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: