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: 81d300630a64d9077e5b3a801e722fd10de4119e
This commit is contained in:
commit
d9bccda151
2 changed files with 33 additions and 3 deletions
|
@ -31,14 +31,33 @@
|
||||||
# 11/04/13 2086 bkowal Updated to merge classes - both legacy and non-legacy.
|
# 11/04/13 2086 bkowal Updated to merge classes - both legacy and non-legacy.
|
||||||
# Minimum to Maximum level of retrieval can now be specified.
|
# Minimum to Maximum level of retrieval can now be specified.
|
||||||
# 11/12/13 2540 bkowal Relocated common methods to PythonOverriderCore.py.
|
# 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
|
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
|
Takes a name (filename and localization path) and the localization type and finds the
|
||||||
file and overrides it, and returns the module
|
file and overrides it, and returns the module
|
||||||
|
@ -51,6 +70,16 @@ def importModule(name, loctype='COMMON_STATIC', level=None):
|
||||||
Returns:
|
Returns:
|
||||||
a module that has all the correct methods after being overridden
|
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()
|
pathManager = PathManager()
|
||||||
tieredFiles = pathManager.getTieredLocalizationFile(loctype, name)
|
tieredFiles = pathManager.getTieredLocalizationFile(loctype, name)
|
||||||
availableLevels = pathManager.getAvailableLevels()
|
availableLevels = pathManager.getAvailableLevels()
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
# Date Ticket# Engineer Description
|
# Date Ticket# Engineer Description
|
||||||
# ------------ ---------- ----------- --------------------------
|
# ------------ ---------- ----------- --------------------------
|
||||||
# 03/12/13 bkowal Initial Creation.
|
# 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
|
BUFFER_SIZE = 512 * 1024
|
||||||
availableLevels = ['BASE', 'CONFIGURED', 'SITE', 'USER']
|
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):
|
loctype='COMMON_STATIC', level=None):
|
||||||
'''
|
'''
|
||||||
@param name: the name of the localization file
|
@param name: the name of the localization file
|
||||||
|
|
Loading…
Add table
Reference in a new issue