From d6d2da51493d7e68b8a0e22bea52c1439b34a75e Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Mon, 27 Jun 2016 12:06:09 +0000
Subject: [PATCH] SSDM-3745: MasterDataRegistrationScriptRunner: create
 interpreter by trial-and-error

SVN: 36755
---
 .../impl/MasterDataRegistrationScriptRunner.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/jython/api/v1/impl/MasterDataRegistrationScriptRunner.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/jython/api/v1/impl/MasterDataRegistrationScriptRunner.java
index bc7cb9b4d73..f37229930f8 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/jython/api/v1/impl/MasterDataRegistrationScriptRunner.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/jython/api/v1/impl/MasterDataRegistrationScriptRunner.java
@@ -24,7 +24,8 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities;
 import ch.systemsx.cisd.common.jython.IJythonInterpreter;
 import ch.systemsx.cisd.common.jython.JythonScriptSplitter;
 import ch.systemsx.cisd.common.jython.JythonUtils;
-import ch.systemsx.cisd.common.jython.evaluator.Evaluator;
+import ch.systemsx.cisd.common.jython.v25.Jython25InterpreterFactory;
+import ch.systemsx.cisd.common.jython.v27.Jython27InterpreterFactory;
 
 /**
  * A class for running python scripts that register master data.
@@ -57,7 +58,7 @@ public class MasterDataRegistrationScriptRunner implements IMasterDataScriptRegi
         MasterDataRegistrationService service = new MasterDataRegistrationService(commonServer);
 
         // Configure the evaluator
-        IJythonInterpreter interpreter = Evaluator.getInterpreterFactory().createInterpreter();
+        IJythonInterpreter interpreter = createInterpreter();
         interpreter.addToPath(jythonPath);
         interpreter.set(SERVICE_VARIABLE_NAME, service);
 
@@ -82,6 +83,17 @@ public class MasterDataRegistrationScriptRunner implements IMasterDataScriptRegi
         service.commit();
     }
 
+    private IJythonInterpreter createInterpreter()
+    {
+        try
+        {
+            return new Jython25InterpreterFactory().createInterpreter();
+        } catch (Exception ex)
+        {
+            return new Jython27InterpreterFactory().createInterpreter();
+        }
+    }
+
     private void checkValidJythonScript(File jythonScript)
     {
         if (false == jythonScript.exists())
-- 
GitLab