Esempio n. 1
0
def slurm_jobid_extract(output):

    match = SLURM_JOBID_EXTRACT_REGEX().search(output)

    if not match:
        raise errors.ExtractionError("Unexpected response from Slurm: %r" %
                                     output)

    return match.group(1)
Esempio n. 2
0
def condor_jobid_extract(output):

    match = CONDOR_JOBID_EXTRACT_REGEX().search(output)

    if not match:
        raise errors.ExtractionError("Unexpected response from Condor: %r" %
                                     output)

    return match.group(1)
Esempio n. 3
0
def pbspro_text_evaluate(out, running, completed):
  "Parses PBSPro qstat text output"

  if not out.strip():
    return

  if not PBSPRO_CENTRAL_HEADER_REGEX().match( out ):
    raise errors.ExtractionError("Unexpected response from PBSPro: %r" % out)

  regex = PBSPRO_CENTRAL_JOBID_REGEX()

  for line in out.splitlines()[2:]:
    match = regex.match( line )

    if not match:
      raise errors.ExtractionError("Unexpected response from PBSPro: %r" % out)

    jobid = match.group( 1 )
    running.add( jobid )
Esempio n. 4
0
def lsf_text_evaluate(out, running, completed):
  "Parses LSF bjobs text output"

  if LSF_CENTRAL_NO_RESULTS_REGEX().search( out ):
    return

  if not LSF_CENTRAL_HEADER_REGEX().match( out ):
    raise errors.ExtractionError("Unexpected response from LSF: %r" % out)

  regex = LSF_CENTRAL_JOBID_REGEX()

  for line in out.splitlines()[1:]:
    match = regex.match( line )

    if not match:
      raise errors.ExtractionError("Unexpected response from LSF: %r" % out)

    jobid = match.group( 1 )
    running.add( jobid )
Esempio n. 5
0
def extract_exit_code_text(output):

    for line in output.splitlines():
        tokens = line.split()

        if len(tokens) == 2 and tokens[0] == "exit_status":
            exit_code = int(tokens[1])  # this should work
            return exit_code

    else:
        raise errors.ExtractionError("Unexpected output: %r" % output)
Esempio n. 6
0
def slurm_single_evaluate(out, err):
  "Evaluates Slurm text output in single mode"

  if err:
    if SLURM_SEARCH_REGEX().search( err ):
      return True

    else:
      raise errors.AbnormalExitError("Slurm error:\n%s" % err)

  state = out.strip()

  if state not in SLURM_CODES:
    raise errors.ExtractionError("Unexpected response from Slurm: %r" % out)

  return state == "CD"
Esempio n. 7
0
def pbs_single_evaluate(out, err):
  "Evaluates PBS text output in single mode"

  if err:
    if PBS_SEARCH_REGEX().search( err ):
      return True

    else:
      raise errors.AbnormalExitError("PBS error:\n%s" % err)

  state = PBS_EVAL_REGEX().search( out )

  if not state:
    raise errors.ExtractionError("Unexpected response from PBS: %r" % out)

  return state.group(1) == "C"
Esempio n. 8
0
def slurm_text_evaluate(out, running, completed):
  "Parses Slurm squeue text output"

  for line in out.splitlines():
    pieces = line.split()

    if len( pieces ) != 2:
      raise errors.ExtractionError("Unexpected response from Slurm: %r" % line)

    ( jobid, status ) = pieces

    assert status in SLURM_CODES

    if status == "CD":
      completed.add( jobid )

    else:
      running.add( jobid )