From 253b14b89517f319d00fa69661dd4c71849d54fb Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Mon, 25 Aug 2014 13:34:36 -0500 Subject: [PATCH] Issue #3500 back port of loadConfig.py to fix gfe starup issue Change-Id: I841af0ac81b86e499c0b52dedab64431e7f1ecd7 Former-commit-id: 960eb2dc294aadc362b4b8e788924aa08de1d194 [formerly 4314f71387f3227396e9125422dc55c52771a856] [formerly cf671dcda8723dbbee91fc16a0e2d08e9f43ab75 [formerly 2a0af03242692708b3e752417ca7d60d28520768]] Former-commit-id: cf671dcda8723dbbee91fc16a0e2d08e9f43ab75 Former-commit-id: f9756abf0a1abfe11fb68a49d139940221dd6504 --- .../python/utility/loadConfig.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py b/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py index 8316ba36d8..775b9b90c8 100644 --- a/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py +++ b/cave/com.raytheon.viz.gfe/python/utility/loadConfig.py @@ -26,31 +26,35 @@ # # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- -# 12/11/09 njensen Initial Creation. -# 08/21/14 3500 bclement fixed loadPreferences except block -# +# 12/11/09 njensen Initial Creation. +# 04/02/2014 #2729 randerso Fixed error handling in loadPreferences # # import types -import LogStream from java.util import HashMap, ArrayList 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: ", config) + import LogStream + import traceback + LogStream.logProblem("Unknown or invalid config file: %s\n%s" % (configName, traceback.format_exc())) raise Exception, e