Convert python2 scripts to python3
Issue-ID: CCSDK-3906
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I68b82108c5cd51a99735f65f964b8ebc16181c1b
15 files changed:
nc.unlock()
nc.disconnect()
nc.unlock()
nc.disconnect()
- except JavaException, err:
+ except JavaException as err:
log.error("Java Exception in the script {}", err)
log.error("Java Exception in the script {}", err)
+ except Exception as err:
log.error("Python Exception in the script {}", err)
def recover(self, runtime_exception, execution_request):
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)
class SamplePythonComponentNode(JythonComponentFunction):
def process(self, execution_request):
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):
return None
def recover(self, runtime_exception, execution_request):
- print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
def process(self, execution_request):
AbstractRAProcessor.process(self, execution_request)
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)
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)
def recover(self, runtime_exception, execution_request):
AbstractRAProcessor.recover(self, runtime_exception, execution_request)
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
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...")
if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
+ 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):
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)
class SamplePythonComponentNode(JythonComponentFunction):
def process(self, execution_request):
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):
return None
def recover(self, runtime_exception, execution_request):
- print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
AbstractRAProcessor.__init__(self)
def process(self, resource_assignment):
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):
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)
def recover(self, runtime_exception, execution_request):
log.error("Exception in the script {}", runtime_exception)
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))
def recover(self, runtime_exception, resource_assignment):
log.error("Exception in the script {}", runtime_exception)
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))
def recover(self, runtime_exception, execution_request):
log.error("Exception in the script {}", runtime_exception)
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))
AbstractComponentFunction.__init__(self)
def process(self, execution_request):
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):
return None
def recover(self, runtime_exception, execution_request):
- print "Recovering calling from parent..."
+ print("Recovering calling from parent...")
class AbstractRAProcessor(ResourceAssignmentProcessor):
def process(self, resource_assignment):
class AbstractRAProcessor(ResourceAssignmentProcessor):
def process(self, resource_assignment):
return None
def recover(self, runtime_exception, resource_assignment):
return None
def recover(self, runtime_exception, resource_assignment):
return None
def set_resource_data_value(self, resource_assignment, value):
return None
def set_resource_data_value(self, resource_assignment, value):
else:
ResourceAssignmentUtils.Companion.setFailedResourceDataValue(
resource_assignment, "Fail to resolve value")
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)
raise BluePrintProcessorException(
"Error on resource assignment. Message = " + err.message)
-from abstract_blueprint_function import AbstractPythonComponentFunction
-from blueprint_constants import *
+from .abstract_blueprint_function import AbstractPythonComponentFunction
+from .blueprint_constants import *
class SampleBlueprintComponent(AbstractPythonComponentFunction):
class SampleBlueprintComponent(AbstractPythonComponentFunction):
def process(self, execution_request):
super(SamplePythonComponentNode, self).process(execution_request)
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)
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)
-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):
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):
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)
class PythonTestScript():
def process(self, execution_request):
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):
return None
def recover(self, runtime_exception, execution_request):
- print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)
class SamplePythonComponentNode(AbstractPythonComponentFunction):
def process(self, execution_request):
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):
return None
def recover(self, runtime_exception, execution_request):
- print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ print("Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH)