Merge "Issue #2712 - Python Overrider can now determine whether or not it is running in Jep so that the main module can be used at all times now." into development

Former-commit-id: adec7acc7c [formerly adec7acc7c [formerly 81d300630a64d9077e5b3a801e722fd10de4119e]]
Former-commit-id: d9bccda151
Former-commit-id: 8b8c5d2258
This commit is contained in:
Lee Venable 2014-02-18 12:21:30 -06:00 committed by Gerrit Code Review
commit 3d2cbdcd21
2 changed files with 33 additions and 3 deletions

View file

@ -31,14 +31,33 @@
# 11/04/13 2086 bkowal Updated to merge classes - both legacy and non-legacy.
# Minimum to Maximum level of retrieval can now be specified.
# 11/12/13 2540 bkowal Relocated common methods to PythonOverriderCore.py.
# 02/13/14 2712 bkowal The main PythonOverrider module can now determine whether
# it is running in Jep or not and make the necessary
# adjustments.
#
#
#
import subprocess
THRIFT_HOST = subprocess.check_output(
'source /awips2/fxa/bin/setup.env; echo $DEFAULT_HOST',
shell=True).strip()
THRIFT_PORT = subprocess.check_output(
'source /awips2/fxa/bin/setup.env; echo $DEFAULT_PORT',
shell=True).strip()
import PythonOverriderCore
from PathManager import PathManager
def importModule(name, loctype='COMMON_STATIC', level=None):
JEP_AVAILABLE = True
try:
from PathManager import PathManager
except ImportError:
import PythonOverriderPure
JEP_AVAILABLE = False
def importModule(name, loctype='COMMON_STATIC', level=None, localizationHost=None,
localizationPort=None, localizedSite=None, localizationUser=None):
"""
Takes a name (filename and localization path) and the localization type and finds the
file and overrides it, and returns the module
@ -51,6 +70,16 @@ def importModule(name, loctype='COMMON_STATIC', level=None):
Returns:
a module that has all the correct methods after being overridden
"""
if not JEP_AVAILABLE:
if localizationHost is None:
localizationHost = THRIFT_HOST
if localizationPort is None:
localizationPort = THRIFT_PORT
return PythonOverriderPure.importModule(name, localizationHost, localizationPort,
localizedSite, localizationUser, loctype, level)
pathManager = PathManager()
tieredFiles = pathManager.getTieredLocalizationFile(loctype, name)
availableLevels = pathManager.getAvailableLevels()

View file

@ -29,6 +29,7 @@
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 03/12/13 bkowal Initial Creation.
# 02/17/14 2712 bkowal Provide a default value for localization site.
#
#
#
@ -48,7 +49,7 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.localization.stream import
BUFFER_SIZE = 512 * 1024
availableLevels = ['BASE', 'CONFIGURED', 'SITE', 'USER']
def importModule(name, localizationHost, localizationPort, localizedSite, localizationUser=None,
def importModule(name, localizationHost, localizationPort, localizedSite=None, localizationUser=None,
loctype='COMMON_STATIC', level=None):
'''
@param name: the name of the localization file