aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/services')
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt10
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt16
2 files changed, 18 insertions, 8 deletions
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
index 600308959..78b7556f3 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
@@ -15,6 +15,7 @@
*/
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.python.core.PyObject
import org.python.util.PythonInterpreter
@@ -38,9 +39,12 @@ open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
bluePrintPython.content = content!!
bluePrintPython.pythonClassName = interfaceName
bluePrintPython.moduleName = "Blueprint Python Script [Class Name = $interfaceName]"
-
- return blueprintPythonInterpreterProxy.getPythonInstance(properties)
+ try {
+ return blueprintPythonInterpreterProxy.getPythonInstance(properties)
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("Failed to execute Jython component ${e.toString()}", e)
+ }
}
//TODO Check potential errors in python scripts
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
index 8998337c9..6e514de49 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
@@ -15,12 +15,14 @@
*/
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.python.core.PyObject
+import org.python.core.PySyntaxError
import org.python.util.PythonInterpreter
-open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrintPython): PythonInterpreter(){
+open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrintPython) : PythonInterpreter() {
- fun getPythonInstance(properties: MutableMap<String, Any>?): PyObject{
+ fun getPythonInstance(properties: MutableMap<String, Any>?): PyObject {
properties?.forEach { (name, value) ->
this.set(name, value)
}
@@ -28,13 +30,17 @@ open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrin
this.exec("import sys")
bluePrintPython.content.let {
- this.exec(bluePrintPython.content)
+ try {
+ this.exec(bluePrintPython.content)
+ } catch (e: PySyntaxError) {
+ throw BluePrintProcessorException("Error executing Jython code! Python error: '${e.toString()}'", e)
+ }
}
val initCommand = bluePrintPython.pythonClassName.plus(" = ").plus(
- bluePrintPython.pythonClassName).plus("()")
+ bluePrintPython.pythonClassName).plus("()")
this.exec(initCommand)
return this.get(bluePrintPython.pythonClassName)
}
-} \ No newline at end of file
+}