From dde9253f159ce4026de9fa13b3b95810b6b64e5b Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Wed, 2 Apr 2014 18:22:51 -0500 Subject: [PATCH] Issue #2729 Fixed error handling in loadPreferences method of loadConfig.py Change-Id: Ic01c265f792d855751aeac9890953600d531c12c Former-commit-id: 8da64048e7649b8060df2b67c7b4e0a9ebf94ff2 [formerly cfec08f8c4ac8552699e9387148ba2e9d0dc9558] Former-commit-id: 69cd6a1598745f60b0bc4773953c6550167d97fc --- .../python/utility/loadConfig.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py b/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py index a81999cea6..775b9b90c8 100644 --- a/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py +++ b/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py @@ -26,8 +26,8 @@ # # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- -# 12/11/09 njensen Initial Creation. -# +# 12/11/09 njensen Initial Creation. +# 04/02/2014 #2729 randerso Fixed error handling in loadPreferences # # @@ -38,18 +38,23 @@ from java.lang import String, Float, Integer, Boolean def loadPreferences(config): try: # import the config file - if type(config) is types.StringType: - globals = loadConfig(config) - elif type(config) is types.ModuleType: - globals = getGlobals(config) + if type(config) is types.StringType: + configName = config + mod = __import__(config) + elif type(config) is types.ModuleType: + configName = config.__name__ + mod = config + + globals = getGlobals(mod) from com.raytheon.viz.gfe import Activator, PythonPreferenceStore prefs = PythonPreferenceStore(globals) Activator.getDefault().setPreferenceStore(prefs) return prefs except Exception, e: - LogStream.logProblem("Unknown or improper config file: ", - configFile, " for user: ", userName) + import LogStream + import traceback + LogStream.logProblem("Unknown or invalid config file: %s\n%s" % (configName, traceback.format_exc())) raise Exception, e