diff options
author | Pavel Aharoni <pa0916@att.com> | 2017-06-11 14:33:57 +0300 |
---|---|---|
committer | Pavel Aharoni <pa0916@att.com> | 2017-06-11 14:33:57 +0300 |
commit | 04387deeab820e75c6d37d2ddd5b514cb7bcfd9e (patch) | |
tree | 2f4dfacba74ec390c4371c62dc96af2b1d5f19ef /jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/JythonRuntime.java | |
parent | fff70fce14ebe7dec3a4d52b7b90cee4414d0562 (diff) |
[SDC-32] separate Tosca Parser from DC
Change-Id: I7e7f31ff2bd92fec22031f75b7051d129a21d01b
Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/JythonRuntime.java')
-rw-r--r-- | jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/JythonRuntime.java | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/JythonRuntime.java b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/JythonRuntime.java deleted file mode 100644 index c5810a9..0000000 --- a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/JythonRuntime.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.openecomp.sdc.toscaparser; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Properties; - -import org.openecomp.sdc.toscaparser.utils.JarExtractor; -import org.python.util.PythonInterpreter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JythonRuntime { - - private static final Logger LOGGER = LoggerFactory.getLogger(JythonRuntime.class); - private final JarExtractor jarExtractor; - private Path homePath; - - public JythonRuntime(JarExtractor jarExtractor) { - this.jarExtractor = jarExtractor; - } - - public void initialize() throws IOException { - tryExtractPyhtonPackages(); - initRuntime(); - } - - private void initRuntime() { - Properties systemProperties = System.getProperties(); - Properties properties = getPythonProperties(); - PythonInterpreter.initialize(systemProperties, properties, new String[0]); - } - - private void tryExtractPyhtonPackages() throws IOException { - homePath = jarExtractor.extractPyhtonPackages(); - } - - private Properties getPythonProperties() { - Properties properties = new Properties(); - if (homePath != null) { - LOGGER.debug("getPythonProperties - Setting python.home to {}", homePath); - properties.put("python.home", homePath.toString()); - } - // Used to prevent: console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0. - properties.put("python.console.encoding", "UTF-8"); - return properties; - } - - public void terminate() throws IOException { - if (homePath != null) { - jarExtractor.deleteDirectory(homePath); - } - } -}
\ No newline at end of file |