Merge "Added option to disable kotlin script cache"
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / python-executor / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / python / executor / scripts / PythonExecutorConfiguration.kt
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  *
4  * Modifications Copyright © 2019 IBM, Bell Canada.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts
20
21 import org.springframework.beans.factory.annotation.Value
22 import org.springframework.boot.context.properties.EnableConfigurationProperties
23 import org.springframework.context.annotation.ComponentScan
24 import org.springframework.context.annotation.Configuration
25 import java.io.File
26 import java.util.Properties
27
28 @Deprecated("CDS won't support JythonService")
29 @Configuration
30 @ComponentScan
31 @EnableConfigurationProperties
32 open class PythonExecutorConfiguration
33
34 @Deprecated("CDS won't support JythonService")
35 @Configuration
36 open class PythonExecutorProperty {
37
38     @Value("\${blueprints.processor.functions.python.executor.executionPath}")
39     lateinit var executionPath: String
40     @Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
41     lateinit var modulePaths: List<String>
42 }
43
44 @Deprecated("CDS won't support JythonService")
45 class PythonExecutorConstants {
46     companion object {
47         const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
48     }
49 }
50
51 @Deprecated("CDS won't support JythonService")
52 open class BluePrintPython(
53     executablePath: String,
54     blueprintPythonPlatform: MutableList<String>,
55     val argv: MutableList<String>
56 ) {
57
58     lateinit var moduleName: String
59     lateinit var pythonClassName: String
60     lateinit var content: String
61     var props: Properties = Properties()
62
63     init {
64         // Build up the python.path
65         val sb = StringBuilder()
66         sb.append(System.getProperty("java.class.path"))
67
68         for (p in blueprintPythonPlatform) {
69             sb.append(File.pathSeparator).append(p)
70         }
71
72         props["python.import.site"] = "true"
73         props.setProperty("python.path", sb.toString())
74         props.setProperty("python.verbose", "error")
75         props.setProperty("python.executable", executablePath)
76     }
77 }