2626
2727HOLD_REASON_SUBCODE = "55"
2828
29+ STATE_ATTRIBUTES = "ClusterId,ProcId,JobStatus,HoldReasonCode,HoldReasonSubCode,HoldReason"
30+
2931subTemplate = """
3032# Environment
3133# -----------
@@ -94,7 +96,7 @@ def getCondorStatus(jobMetadata):
9496 """parse the condor_q or condor_history output for the job status
9597
9698 :param jobMetadata: dict with job metadata
97- :type lines : dict[str, str | int]
99+ :type jobMetadata : dict[str, str | int]
98100 :returns: Status as known by DIRAC, and a reason if the job is being held
99101 """
100102 if jobMetadata ["JobStatus" ] != 5 :
@@ -272,10 +274,9 @@ def getJobStatus(self, **kwargs):
272274
273275 # Prepare the command to get the status of the jobs
274276 cmdJobs = " " .join (str (jobID ) for jobID in jobIDList )
275- attributes = "ClusterId,ProcId,JobStatus,HoldReasonCode,HoldReasonSubCode,HoldReason"
276277
277278 # Get the status of the jobs currently active
278- cmd = "condor_q %s -attributes %s -json" % (cmdJobs , attributes )
279+ cmd = "condor_q %s -attributes %s -json" % (cmdJobs , STATE_ATTRIBUTES )
279280 sp = subprocess .Popen (
280281 shlex .split (cmd ),
281282 stdout = subprocess .PIPE ,
@@ -290,10 +291,10 @@ def getJobStatus(self, **kwargs):
290291 resultDict ["Message" ] = error
291292 return resultDict
292293
293- jobMetadata = json .loads (output )
294+ jobsMetadata = json .loads (output )
294295
295296 # Get the status of the jobs in the history
296- condorHistCall = "condor_history %s -attributes %s -json" % (cmdJobs , attributes )
297+ condorHistCall = "condor_history %s -attributes %s -json" % (cmdJobs , STATE_ATTRIBUTES )
297298 sp = subprocess .Popen (
298299 shlex .split (condorHistCall ),
299300 stdout = subprocess .PIPE ,
@@ -308,12 +309,12 @@ def getJobStatus(self, **kwargs):
308309 resultDict ["Message" ] = error
309310 return resultDict
310311
311- jobMetadata += json .loads (output )
312+ jobsMetadata += json .loads (output )
312313
313314 statusDict = {}
314- # Build a set of job IDs found in jobMetadata
315+ # Build a set of job IDs found in jobsMetadata
315316 foundJobIDs = set ()
316- for jobDict in jobMetadata :
317+ for jobDict in jobsMetadata :
317318 jobID = "%s.%s" % (jobDict ["ClusterId" ], jobDict ["ProcId" ])
318319 statusDict [jobID ], _ = getCondorStatus (jobDict )
319320 foundJobIDs .add (jobID )
0 commit comments