Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-19 08:00:01

0001 from pilot.common.errorcodes import ErrorCodes as PilotErrorCodesObj
0002 from pilot.util import auxiliary as PilotAux
0003 
0004 
0005 class PilotErrors(PilotErrorCodesObj):
0006     """Pilot error handling"""
0007 
0008     pilot_error_msg = PilotErrorCodesObj._error_messages
0009     pilot_error_msg.update(
0010         {
0011             # can have additional error codes here
0012         }
0013     )
0014 
0015     getErrorCodes = [1097, 1099, 1100, 1103, 1107, 1113, 1130, 1145, 1151, 1164, 1167, 1168, 1171, 1175, 1178, 1179, 1180, 1182]
0016     putErrorCodes = [1101, 1114, 1122, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1140, 1141, 1152, 1154, 1155, 1181]
0017     recoverableErrorCodes = [0] + putErrorCodes
0018 
0019     # Error codes that will issue a Pilot-controlled resubmission
0020     PilotResubmissionErrorCodes = [
0021         1008,
0022         1098,
0023         1099,
0024         1110,
0025         1113,
0026         1114,
0027         1115,
0028         1116,
0029         1117,
0030         1137,
0031         1139,
0032         1151,
0033         1152,
0034         1171,
0035         1172,
0036         1177,
0037         1179,
0038         1180,
0039         1181,
0040         1182,
0041         1188,
0042         1189,
0043         1195,
0044         1196,
0045         1197,
0046         1219,
0047     ]
0048 
0049     # Error codes used with FAX fail-over (only an error code in this list will allow FAX fail-over)
0050     PilotFAXErrorCodes = [1103] + PilotResubmissionErrorCodes
0051 
0052     # Mapping between payload exit code and pilot errors
0053     pilot_code_dict = PilotAux.get_error_code_translation_dictionary()
0054     avail_exit_codes = [value[0] for value in pilot_code_dict.values()]
0055 
0056     def getPilotErrorDiag(self, code=0):
0057         """Return text corresponding to error code"""
0058         pilotErrorDiag = ""
0059         if code in self.pilot_error_msg.keys():
0060             pilotErrorDiag = self.pilot_error_msg[code]
0061         else:
0062             pilotErrorDiag = "Unknown pilot error code"
0063         return pilotErrorDiag
0064 
0065     def isGetErrorCode(self, code=0):
0066         """Determine whether code is in the put error list or not"""
0067         state = False
0068         if code in self.getErrorCodes:
0069             state = True
0070         return state
0071 
0072     def isPutErrorCode(self, code=0):
0073         """Determine whether code is in the put error list or not"""
0074         state = False
0075         if code in self.putErrorCodes:
0076             state = True
0077         return state
0078 
0079     @classmethod
0080     def isRecoverableErrorCode(self, code=0):
0081         """Determine whether code is a recoverable error code or not"""
0082         return code in self.recoverableErrorCodes
0083 
0084     def isPilotResubmissionErrorCode(self, code=0):
0085         """Determine whether code issues a Pilot-controlled resubmission"""
0086         state = False
0087         if code in self.PilotResubmissionErrorCodes:
0088             state = True
0089         return state
0090 
0091     def isPilotFAXErrorCode(self, code=0):
0092         """Determine whether code allows for a FAX fail-over"""
0093         state = False
0094         if code in self.PilotFAXErrorCodes:
0095             state = True
0096         return state
0097 
0098     @classmethod
0099     def getErrorStr(self, code):
0100         """
0101         Avoids exception if an error is not in the dictionary.
0102         An empty string is returned if the error is not in the dictionary.
0103         """
0104         return self.pilot_error_msg.get(code, "")
0105 
0106     def getErrorName(self, code):
0107         """From the error code to get the error name"""
0108         for k in self.__class__.__dict__.keys():
0109             if self.__class__.__dict__[k] == code:
0110                 return k
0111         return None
0112 
0113     def convertToPilotErrors(self, exit_code):
0114         """
0115         Convert payload exit code to pilot error code and error dialogue message
0116         """
0117         pilot_error_code, pilot_error_diag = None, ""
0118         if exit_code in self.avail_exit_codes:
0119             pilot_error_code = PilotAux.convert_to_pilot_error_code(exit_code)
0120             pilot_error_diag = self.getPilotErrorDiag(pilot_error_code)
0121         return pilot_error_code, pilot_error_diag
0122 
0123 
0124 class PilotException(Exception):
0125     def __init__(self, message, code=PilotErrors.GENERALERROR, state="", *args):
0126         self.code = code
0127         self.state = state
0128         self.message = message
0129         super(PilotException, self).__init__(*args)
0130 
0131     @property
0132     def code(self):
0133         return self._code
0134 
0135     @code.setter
0136     def code(self, code):
0137         self._code = code
0138         self.code_description = PilotErrors.getErrorStr(code)
0139 
0140     def __str__(self):
0141         return "%s: %s: %s%s" % (self.__class__.__name__, self.code, self.message, " : %s" % self.args if self.args else "")
0142 
0143     def __repr__(self):
0144         return "%s: %s: %s%s" % (self.__class__.__name__, repr(self.code), repr(self.message), " : %s" % repr(self.args) if self.args else "")