Issue #3500 back port of loadConfig.py to fix gfe starup issue

Change-Id: I841af0ac81b86e499c0b52dedab64431e7f1ecd7

Former-commit-id: 960eb2dc29 [formerly 4314f71387] [formerly cf671dcda8 [formerly 2a0af03242692708b3e752417ca7d60d28520768]]
Former-commit-id: cf671dcda8
Former-commit-id: f9756abf0a
This commit is contained in:
Brian Clements 2014-08-25 13:34:36 -05:00
parent d2c4e847ba
commit 253b14b895

View file

@ -26,31 +26,35 @@
# #
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# 12/11/09 njensen Initial Creation. # 12/11/09 njensen Initial Creation.
# 08/21/14 3500 bclement fixed loadPreferences except block # 04/02/2014 #2729 randerso Fixed error handling in loadPreferences
#
# #
# #
import types import types
import LogStream
from java.util import HashMap, ArrayList from java.util import HashMap, ArrayList
from java.lang import String, Float, Integer, Boolean from java.lang import String, Float, Integer, Boolean
def loadPreferences(config): def loadPreferences(config):
try: try:
# import the config file # import the config file
if type(config) is types.StringType: if type(config) is types.StringType:
globals = loadConfig(config) configName = config
elif type(config) is types.ModuleType: mod = __import__(config)
globals = getGlobals(config) elif type(config) is types.ModuleType:
configName = config.__name__
mod = config
globals = getGlobals(mod)
from com.raytheon.viz.gfe import Activator, PythonPreferenceStore from com.raytheon.viz.gfe import Activator, PythonPreferenceStore
prefs = PythonPreferenceStore(globals) prefs = PythonPreferenceStore(globals)
Activator.getDefault().setPreferenceStore(prefs) Activator.getDefault().setPreferenceStore(prefs)
return prefs return prefs
except Exception, e: 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 raise Exception, e