예제 #1
0
  def update(self):

    try:
      process = subprocess.Popen(
        self.command,
        stdout = subprocess.PIPE,
        stderr = subprocess.PIPE
        )

    except OSError as e:
      raise errors.ExecutableError("'%s': %s" % ( " ".join( self.command ), e ))

    ( out, err ) = process.communicate()

    if process.poll():
      message = "Poll error: '%s' exited abnormally (code %s, message %s)" % (
        " ".join( self.command ),
        process.poll(),
        err,
        )
      raise errors.AbnormalExitError(message)

    self.running.clear()
    self.completed.clear()

    self.evaluate( out = out, running = self.running, completed = self.completed )
    self.polltime = time.time()
예제 #2
0
    def __call__(self, name, executable, script, include, cleanup):

        (process, outfile, errfile) = self.create(name=name)

        (out, err) = process.communicate(
            input=self.handler.script(include=include,
                                      executable=executable,
                                      script=script,
                                      cwd=self.cwd))

        if process.poll():
            message = "Submission error: '%s' exited abnormally (code %s, message %s)" % (
                " ".join(self.cmds),
                process.poll(),
                err,
            )
            raise errors.AbnormalExitError(message)

        return self.handler(
            jobid=self.extract(output=out),
            poller=self.poller,
            outfile=outfile,
            errfile=errfile,
            additional=cleanup,
            qdel=self.qdel,
        )
예제 #3
0
def sge_single_evaluate(out, err):
  "Evaluates SGE text output in single mode"

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

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

  else:
    return False
예제 #4
0
    def outcome(self, timeout, polltime):

        exitcode = self.exit_code()
        assert exitcode is not None

        stdout = self.get_stdout(timeout=timeout, polltime=polltime)
        stderr = self.get_stderr(timeout=timeout, polltime=polltime)

        if stdout is None or stderr is None:
            stdout = self.process.stdout.read()
            stderr = self.process.stderr.read()
            raise errors.AbnormalExitError("Queue error:%s\n%s" %
                                           (stdout, stderr))

        return Finished(stdout=stdout, stderr=stderr, exitcode=exitcode)
예제 #5
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"
예제 #6
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"
예제 #7
0
    def __call__(self, name, executable, script, include, cleanup):

        outfile = "%s.out" % name
        errfile = "%s.err" % name
        scriptfile = "%s.condor.script" % name
        logfile = "%s.condor.xml" % name

        with open(scriptfile, "w") as ofile:
            ofile.write(
                self.handler.script(include=include,
                                    executable=executable,
                                    script=script))

        import os
        import stat
        os.chmod(scriptfile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)

        process = self.create()

        (out,
         err) = process.communicate(input=self.script %
                                    (scriptfile, outfile, errfile, logfile))

        if process.poll():
            message = "Submission error: '%s' exited abnormally (code %s, message %s)" % (
                " ".join(self.cmds),
                process.poll(),
                err,
            )
            raise errors.AbnormalExitError(message)

        return self.handler(
            jobid=self.extract(output=out),
            poller=self.poller,
            outfile=outfile,
            errfile=errfile,
            logfile=logfile,
            additional=cleanup + [scriptfile],
            qdel=self.qdel,
        )
예제 #8
0
    def outcome(self, timeout, polltime):

        # Use accounting file to return exit code
        try:
            process = subprocess.Popen(["qacct", "-j", self.jobid],
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)

        except OSError as e:
            raise errors.ExecutableError("'qacct -j %s': %s" % (self.jobid, e))

        (out, err) = process.communicate()

        if process.poll():
            raise errors.AbnormalExitError("Accounting error:\n%s" % err)

        exit_code = extract_exit_code_text(output=out)

        return Finished(
            stdout=self.get_stdout(timeout=timeout, polltime=polltime),
            stderr=self.get_stderr(timeout=timeout, polltime=polltime),
            exitcode=exit_code,
        )