summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services/execution-service
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2019-07-16 18:18:05 -0400
committerOleg Mitsura <oleg.mitsura@amdocs.com>2019-07-16 18:19:03 -0400
commit47dd8e2e69f8a754c620a22b926faad2a02439f5 (patch)
tree55d2e95dbf2774af5f5377ffc90e0f8b10bc5d94 /ms/blueprintsprocessor/modules/services/execution-service
parent38c837e19ceac983bfbfdfca811aeb992431077a (diff)
bubble up python error to CDS output
Issue-ID: CCSDK-1494 Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com> Change-Id: Iac9fc47ef51d92da507cc6d2dfee252490a2313a
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/execution-service')
-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
+}