def getFinalState(result): """ Figure out the final job state (finished or failed) Simplies job recovery """ state = "failed" # job has failed if transExitCode != 0 if result[1] != 0: state = "failed" else: error = PilotErrors() # job has finished if pilotErrorCode is in the allowed list or recoverable jobs if ((error.isRecoverableErrorCode(result[2])) or (result[2] == error.ERR_KILLSIGNAL and result[0] == "holding")): state = "finished" return state