def TestReceiveRemoteCompletion(self): ''' Example 2: Calls a method that returns a completion If the completion contains an error, then: Catches the exception, prints it locally sends it to the logging system Parameters: None Returns: Nothing Raises: ACSErrTypeCommonImpl.CouldntAccessComponentExImpl ''' self.logger.logTrace( "ClientErrorComponent.TestReceiveRemoteCompletion") if self.foo == None: raise ACSErrTypeCommonImpl.CouldntAccessComponentExImpl() try: # OK Completion self.logger.logInfo( "Example 2a: Calls a method that returns an OK completion.") comp = self.foo.completionFromException(0) addComplHelperMethods(comp) if comp.isErrorFree() == 1: self.logger.logInfo("Completion Ok, without error trace") else: self.logger.logInfo("Completion with error trace (UNEXPECTED)") comp.log(self.logger) # ERROR completion with an error trace inside. self.logger.logInfo( "Example 2b: Calls a method that returns an Error completion, of depth 3." ) comp2 = self.foo.completionFromException(3) addComplHelperMethods(comp2) if comp2.isErrorFree() == 1: self.logger.logInfo( "Completion Ok, without error trace (UNEXPECTED)") else: self.logger.logInfo("Completion with error trace") comp2.log(self.logger) except CORBA.SystemException, ex: # Map...... acsPrintExcDebug() displayMessageEx = ACSErrTypeCommonImpl.GenericErrorExImpl() displayMessageEx.setErrorDesc( "completionFromException has thrown an UNEXPECTED CORBA exception" ) displayMessageEx.log(self.logger)
def TestReceiveRemoteCompletion(self): ''' Example 2: Calls a method that returns a completion If the completion contains an error, then: Catches the exception, prints it locally sends it to the logging system Parameters: None Returns: Nothing Raises: ACSErrTypeCommonImpl.CouldntAccessComponentExImpl ''' self.logger.logTrace("ClientErrorComponent.TestReceiveRemoteCompletion") if self.foo == None: raise ACSErrTypeCommonImpl.CouldntAccessComponentExImpl() try: # OK Completion self.logger.logInfo("Example 2a: Calls a method that returns an OK completion.") comp = self.foo.completionFromException(0) addComplHelperMethods(comp) if comp.isErrorFree() == 1: self.logger.logInfo("Completion Ok, without error trace") else: self.logger.logInfo("Completion with error trace (UNEXPECTED)") comp.log(self.logger) # ERROR completion with an error trace inside. self.logger.logInfo("Example 2b: Calls a method that returns an Error completion, of depth 3.") comp2 = self.foo.completionFromException(3) addComplHelperMethods(comp2) if comp2.isErrorFree() == 1: self.logger.logInfo("Completion Ok, without error trace (UNEXPECTED)") else: self.logger.logInfo("Completion with error trace") comp2.log(self.logger) except CORBA.SystemException, ex: # Map...... acsPrintExcDebug() displayMessageEx = ACSErrTypeCommonImpl.GenericErrorExImpl() displayMessageEx.setErrorDesc("completionFromException has thrown an UNEXPECTED CORBA exception") displayMessageEx.log(self.logger)
self.logger.logTrace( "ClientErrorComponent.testCompletionFromCompletion") self.logger.logInfo( "Example 6a: completionFromCompletion with depth 0") try: comp = self.foo.completionFromCompletion(0) except Exception, ex: ex2 = ACSErrTypeCommonImpl.UnknownExImpl(exception=ex) ex2.addData( "ErrorDesc", "completionFromCompletion has thrown an UNEXPECTED exception") ex2.log(self.logger) addComplHelperMethods(comp) if comp.isErrorFree() == 1: self.logger.logInfo("Completion Ok, without error trace") else: self.logger.logInfo("Completion with error trace (UNEXPECTED)") comp.log(self.logger) self.logger.logInfo( "Example 6b: completionFromCompletion with depth 3") try: comp = self.foo.completionFromCompletion(3) except Exception, ex: ex2 = ACSErrTypeCommonImpl.UnknownExImpl(exception=ex) ex2.addData( "ErrorDesc",
# # BUGS # #------------------------------------------------------------------------ # from Acspy.Common.Log import getLogger from Acspy.Common.Err import addComplHelperMethods from Acspy.Common.Err import createErrorTrace from ACSErr import Completion et = createErrorTrace(51L, 4L, level=-1) #go through the usual spiel to get a completion completion = Completion(132922080005000000L, 51L, 4L, [et]) #add the helper methods addComplHelperMethods(completion) #test the helper methods print "The timestamp is:", completion.getTimeStamp() print "The type is:", completion.getType() print "The code is:", completion.getCode() print "The completion is error free:", completion.isErrorFree() print "Logging the completion:", completion.log() print "Adding data to the completion:", completion.addData("some_name", 42) print "Relogging the completion:", completion.log() # # ___oOo___
''' Calls completionFromCompletion, with differents depths, catches the exceptions(if any, there shouldn't be if depth<=0) ''' self.logger.logTrace("ClientErrorComponent.testCompletionFromCompletion") self.logger.logInfo("Example 6a: completionFromCompletion with depth 0") try: comp = self.foo.completionFromCompletion(0) except Exception, ex: ex2 = ACSErrTypeCommonImpl.UnknownExImpl(exception=ex) ex2.addData("ErrorDesc","completionFromCompletion has thrown an UNEXPECTED exception") ex2.log(self.logger) addComplHelperMethods(comp) if comp.isErrorFree() == 1: self.logger.logInfo("Completion Ok, without error trace") else: self.logger.logInfo("Completion with error trace (UNEXPECTED)") comp.log(self.logger) self.logger.logInfo("Example 6b: completionFromCompletion with depth 3") try: comp = self.foo.completionFromCompletion(3) except Exception, ex: ex2 = ACSErrTypeCommonImpl.UnknownExImpl(exception=ex) ex2.addData("ErrorDesc","completionFromCompletion has thrown an UNEXPECTED exception") ex2.log(self.logger)
from Acspy.Common.Err import addComplHelperMethods from Acspy.Common.Err import createErrorTrace from ACSErr import Completion et = createErrorTrace(51L, 4L, level=-1) #go through the usual spiel to get a completion completion = Completion(132922080005000000L, 51L, 4L, [et]) #add the helper methods addComplHelperMethods(completion) #test the helper methods print "The timestamp is:", completion.getTimeStamp() print "The type is:", completion.getType() print "The code is:", completion.getCode() print "The completion is error free:", completion.isErrorFree() print "Logging the completion:", completion.log() print "Adding data to the completion:", completion.addData("some_name", 42) print "Relogging the completion:", completion.log() # # ___oOo___