diff options
author | Brinda Santh Muthuramalingam <brindasanth@in.ibm.com> | 2019-07-17 13:14:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-07-17 13:14:20 +0000 |
commit | d42b731ce248b58d530901f02ac924e551b8d519 (patch) | |
tree | 1a6e61386a3f156499a41b0725ec9492ba196c2b /ms/blueprintsprocessor/modules/services | |
parent | 9cb361d7fb17120e4c68ff370f7cb95b15d638e1 (diff) | |
parent | 47dd8e2e69f8a754c620a22b926faad2a02439f5 (diff) |
Merge "bubble up python error to CDS output"
Diffstat (limited to 'ms/blueprintsprocessor/modules/services')
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 +} |