Merge "Omaha #3427 decoder interface now takes full path to jar" into omaha_14.4.1

Former-commit-id: f697efd6be [formerly 964582d277 [formerly 8587fe7d4577fc1667c75e79535e81129b871e35]]
Former-commit-id: 964582d277
Former-commit-id: 549b05fd37
This commit is contained in:
Nate Jensen 2014-08-04 13:56:37 -05:00 committed by Gerrit Code Review
commit 0039bd4e6a
2 changed files with 11 additions and 8 deletions

View file

@ -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;

View file

@ -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):