Omaha #3427 decoder interface now takes full path to jar
Change-Id: I8212017cce74cb70314a2a6f72fad72f59ff19fb Former-commit-id:32d46b0155
[formerly 1aee051869b8aac10a233a142f758fdca82c11ab] Former-commit-id:516575c326
This commit is contained in:
parent
e152bc9a6a
commit
3687dd978c
2 changed files with 11 additions and 8 deletions
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.edex.python.decoder;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
|
||||
import jep.JepException;
|
||||
|
@ -46,6 +47,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 2, 2009 njensen Initial creation
|
||||
* Jul 10, 2014 2914 garmendariz Remove EnvProperties
|
||||
* Aug 04, 2014 3427 bclement decoder interface now takes full path to jar
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -88,13 +90,15 @@ public class PythonDecoderFactory {
|
|||
* python module. Synchronized as zipimport has race condition that only
|
||||
* allows one interpreter to load a given jar file at a time.
|
||||
*
|
||||
* @param pluginName
|
||||
* @param pluginFQN
|
||||
* @param moduleName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static synchronized PythonScript makePythonDecoder(String pluginFQN,
|
||||
String moduleName) throws Exception {
|
||||
PythonScript py = null;
|
||||
String jarpath = Paths.get(pluginDir, pluginFQN + ".jar").toString();
|
||||
int retryCount = 0;
|
||||
// we try multiple times cause once in a blue moon we get an error on
|
||||
// zlib that is an extremely rare fluke
|
||||
|
@ -104,13 +108,12 @@ public class PythonDecoderFactory {
|
|||
py = new PythonScript(decoderInterface, includePath,
|
||||
PythonDecoder.class.getClassLoader());
|
||||
HashMap<String, Object> argMap = new HashMap<String, Object>();
|
||||
argMap.put("pluginDir", pluginDir);
|
||||
argMap.put("pluginFQN", pluginFQN);
|
||||
argMap.put("jarpath", jarpath);
|
||||
argMap.put("moduleName", moduleName);
|
||||
py.execute("loadModule", argMap);
|
||||
} catch (JepException e) {
|
||||
logger.error(
|
||||
"Error instantiating python decoder " + moduleName, e);
|
||||
logger.error("Error instantiating python decoder " + moduleName
|
||||
+ " from jar " + jarpath, e);
|
||||
if (py != null) {
|
||||
py.dispose();
|
||||
py = null;
|
||||
|
|
|
@ -34,14 +34,14 @@ from java.util import ArrayList
|
|||
# ------------- -------- ----------- --------------------------
|
||||
# Sep 22, 2008 njensen Initial Creation.
|
||||
# Oct 03, 2013 2402 bsteffen Make PythonDecoder more extendable.
|
||||
# Aug 04, 2014 3427 bclement loadModule() now takes full path to jar
|
||||
#
|
||||
#
|
||||
#
|
||||
def loadModule(pluginDir, pluginFQN, moduleName):
|
||||
jarname = pluginDir + pluginFQN + ".jar"
|
||||
def loadModule(jarpath, moduleName):
|
||||
|
||||
if not sys.modules.has_key(moduleName):
|
||||
jar = zipimport.zipimporter(jarname)
|
||||
jar = zipimport.zipimporter(jarpath)
|
||||
jar.load_module(moduleName)
|
||||
|
||||
def decode(moduleName, **kwargs):
|
||||
|
|
Loading…
Add table
Reference in a new issue