Convert scripts to python3 88/134888/1
authorDan Timoney <dtimoney@att.com>
Wed, 14 Jun 2023 21:07:55 +0000 (17:07 -0400)
committerDan Timoney <dtimoney@att.com>
Wed, 14 Jun 2023 21:07:55 +0000 (17:07 -0400)
Convert python2 scripts to python3

Issue-ID: CCSDK-3906
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I68b82108c5cd51a99735f65f964b8ebc16181c1b

15 files changed:
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py
components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/DefaultGetNetConfig.py
components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SamplePythonComponentNode.py
components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py
components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/ConfigDeploy.py
components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py
components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py
components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py
components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py
components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py
ms/blueprintsprocessor/functions/python-executor/src/test/resources/PythonTestScript.py
ms/blueprintsprocessor/functions/python-executor/src/test/resources/scripts/SamplePythonComponentNode.py

index 2fd6c66..a11b0d4 100644 (file)
@@ -42,11 +42,11 @@ class NetconfRpcExample(AbstractScriptComponentFunction):
             nc.unlock()
             nc.disconnect()
 
-        except JavaException, err:
+        except JavaException as err:
             log.error("Java Exception in the script {}", err)
-        except Exception, err:
+        except Exception as err:
             log.error("Python Exception in the script {}", err)
 
     def recover(self, runtime_exception, execution_request):
-        print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index 86c9ff1..1ee4182 100644 (file)
@@ -5,9 +5,9 @@ from blueprint_constants import *
 class SamplePythonComponentNode(JythonComponentFunction):
 
     def process(self, execution_request):
-        print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
     def recover(self, runtime_exception, execution_request):
-        print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index 30b9ff9..beb544b 100644 (file)
@@ -10,7 +10,7 @@ class SampleRAProcessor(AbstractRAProcessor):
     def process(self, execution_request):
 
         AbstractRAProcessor.process(self, execution_request)
-        print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         if self.ra_valid is True:
             value = self.resolve_values_script(execution_request, self.value_to_resolve)
             self.set_resource_data_value(execution_request, value)
@@ -20,10 +20,10 @@ class SampleRAProcessor(AbstractRAProcessor):
 
     def recover(self, runtime_exception, execution_request):
         AbstractRAProcessor.recover(self, runtime_exception, execution_request)
-        print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
     def resolve_values_script(self, execution_request, value_to_resolve):
         # TODO : DO business logic here
-        print "Resolve value for " + value_to_resolve + " here..."
+        print("Resolve value for " + value_to_resolve + " here...")
         return "test_python"
index 5038caa..15eb38c 100755 (executable)
@@ -37,12 +37,12 @@ class DefaultGetNetConfig(AbstractPythonComponentFunction):
                 if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
                     errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
 
-        except Exception, err:
+        except Exception as err:
             log.info("Exception in the script {}",err.getMessage())
             status = netconf_constant.STATUS_FAILURE
             errorMessage = "Get Running Config Failure ::"+err.getMessage()
 
     def  recover(self, runtime_exception, execution_request):
-        print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
index 86c9ff1..1ee4182 100755 (executable)
@@ -5,9 +5,9 @@ from blueprint_constants import *
 class SamplePythonComponentNode(JythonComponentFunction):
 
     def process(self, execution_request):
-        print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
     def recover(self, runtime_exception, execution_request):
-        print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index acf12b3..c76c589 100755 (executable)
@@ -8,10 +8,10 @@ class SampleRAProcessor(AbstractRAProcessor):
         AbstractRAProcessor.__init__(self)
 
     def process(self, resource_assignment):
-        print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH)
         self.set_resource_data_value(resource_assignment, "")
         return None
 
     def recover(self, runtime_exception, resource_assignment):
-        print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index 2146be7..7e80fd8 100644 (file)
@@ -48,5 +48,5 @@ class ConfigDeploy(NetconfComponentFunction):
 
   def recover(self, runtime_exception, execution_request):
         log.error("Exception in the script {}", runtime_exception)
-        print self.addError(runtime_exception.cause.message)
+        print(self.addError(runtime_exception.cause.message))
         return None
index 8482a89..66c6e32 100644 (file)
@@ -38,5 +38,5 @@ class DescriptionExample(AbstractRAProcessor):
 
     def recover(self, runtime_exception, resource_assignment):
         log.error("Exception in the script {}", runtime_exception)
-        print self.addError(runtime_exception.cause.message)
+        print(self.addError(runtime_exception.cause.message))
         return None
index 40b3c3d..dbfdade 100644 (file)
@@ -39,5 +39,5 @@ class Rollback(NetconfComponentFunction):
 
   def recover(self, runtime_exception, execution_request):
         log.error("Exception in the script {}", runtime_exception)
-        print self.addError(runtime_exception.cause.message)
+        print(self.addError(runtime_exception.cause.message))
         return None
index a9d4d45..916ef9b 100644 (file)
@@ -7,9 +7,9 @@ class AbstractPythonComponentFunction(AbstractComponentFunction):
         AbstractComponentFunction.__init__(self)
 
     def process(self, execution_request):
-        print "Processing calling from parent..."
+        print("Processing calling from parent...")
         return None
 
     def recover(self, runtime_exception, execution_request):
-        print "Recovering calling from parent..."
+        print("Recovering calling from parent...")
         return None
index 05fe2e0..9f0fd4a 100644 (file)
@@ -9,11 +9,11 @@ from org.onap.ccsdk.cds.controllerblueprints.core import \
 class AbstractRAProcessor(ResourceAssignmentProcessor):
 
     def process(self, resource_assignment):
-        print "Processing.."
+        print("Processing..")
         return None
 
     def recover(self, runtime_exception, resource_assignment):
-        print "Recovering.."
+        print("Recovering..")
         return None
 
     def set_resource_data_value(self, resource_assignment, value):
@@ -24,6 +24,6 @@ class AbstractRAProcessor(ResourceAssignmentProcessor):
             else:
                 ResourceAssignmentUtils.Companion.setFailedResourceDataValue(
                     resource_assignment, "Fail to resolve value")
-        except BluePrintProcessorException, err:
+        except BluePrintProcessorException as err:
             raise BluePrintProcessorException(
                 "Error on resource assignment. Message = " + err.message)
index a1e6c5d..ca0be57 100644 (file)
@@ -1,5 +1,5 @@
-from abstract_blueprint_function import AbstractPythonComponentFunction
-from blueprint_constants import *
+from .abstract_blueprint_function import AbstractPythonComponentFunction
+from .blueprint_constants import *
 
 
 class SampleBlueprintComponent(AbstractPythonComponentFunction):
@@ -9,10 +9,10 @@ class SampleBlueprintComponent(AbstractPythonComponentFunction):
 
     def process(self, execution_request):
         super(SamplePythonComponentNode, self).process(execution_request)
-        print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
     def recover(self, runtime_exception, execution_request):
         super(SamplePythonComponentNode, self).recover(runtime_exception, execution_request)
-        print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index fa82108..5e78981 100644 (file)
@@ -1,14 +1,14 @@
-from abstract_ra_processor import AbstractRAProcessor
-from blueprint_constants import *
+from .abstract_ra_processor import AbstractRAProcessor
+from .blueprint_constants import *
 
 
 class SampleRAProcessorFunction(AbstractRAProcessor):
 
     def process(self, resource_assignment):
-        print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH)
         self.set_resource_data_value(resource_assignment, "")
         return None
 
     def recover(self, runtime_exception, resource_assignment):
-        print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index 42b611b..d2d023b 100644 (file)
@@ -1,9 +1,9 @@
 class PythonTestScript():
 
     def process(self, execution_request):
-        print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
     def recover(self, runtime_exception, execution_request):
-        print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
index f1b614a..7150e43 100644 (file)
@@ -5,10 +5,10 @@ from blueprint_constants import *
 class SamplePythonComponentNode(AbstractPythonComponentFunction):
 
     def process(self, execution_request):
-        print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None
 
     def recover(self, runtime_exception, execution_request):
-        print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+        print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
         return None