Greps through the job's current status to see if
        it returned with the requested status.
        status_type: complete, error
778705
def _grep_status(self, status_type):
        
        args = "qstat -f {}".format(self.id).split()
        res, _ = call(args)
        exit_status = [line for line in res.split('\n')
                if 'exit_status' in line]
        try:
            _, __, code = exit_status[0].split()
        except IndexError:
            code = None

        if status_type == 'complete' and code == '0':
            return True
        elif status_type == 'error' and code != '0':
            return True
        else:
            return False
899558
def check_finished(self):
        """"""
        changed = False
        for key in list(self.processes.keys()):
            # Poll process and check if it finshed
            process = self.processes[key]
            process.poll()
            if process.returncode is not None:
                # If a process is terminated by `stop` or `kill`
                # we want to queue it again instead closing it as failed.
                if key not in self.stopping:
                    # Get std_out and err_out
                    output, error_output = process.communicate()

                    descriptor = self.descriptors[key]
                    descriptor['stdout'].seek(0)
                    descriptor['stderr'].seek(0)
                    output = get_descriptor_output(descriptor['stdout'], key, handler=self)
                    error_output = get_descriptor_output(descriptor['stderr'], key, handler=self)

                    # Mark queue entry as finished and save returncode
                    self.queue[key]['returncode'] = process.returncode
                    if process.returncode != 0:
                        self.queue[key]['status'] = 'failed'
                    else:
                        self.queue[key]['status'] = 'done'

                    # Add outputs to queue
                    self.queue[key]['stdout'] = output
                    self.queue[key]['stderr'] = error_output
                    self.queue[key]['end'] = str(datetime.now().strftime("%H:%M"))

                    self.queue.write()
                    changed = True
                else:
                    self.stopping.remove(key)
                    if key in self.to_remove:
                        self.to_remove.remove(key)
                        del self.queue[key]
                    else:
                        if key in self.to_stash:
                            self.to_stash.remove(key)
                            self.queue[key]['status'] = 'stashed'
                        else:
                            self.queue[key]['status'] = 'queued'
                        self.queue[key]['start'] = ''
                        self.queue[key]['end'] = ''

                    self.queue.write()

                self.clean_descriptor(key)
                del self.processes[key]

        # If anything should be logged we return True
        return changed
518661
def get_status(self):
    
    self.__update_state()
    if self._state.active:
      return self.RUNNING
    else:
      return self._state.result_status
89224
def getstate(self):
        
        # the jobstore never existed
        if not os.path.exists(self.jobstorefile):
            logging.info('Workflow ' + self.run_id + ': QUEUED')
            return "QUEUED", -1

        # completed earlier
        if os.path.exists(self.statcompletefile):
            logging.info('Workflow ' + self.run_id + ': COMPLETE')
            return "COMPLETE", 0

        # errored earlier
        if os.path.exists(self.staterrorfile):
            logging.info('Workflow ' + self.run_id + ': EXECUTOR_ERROR')
            return "EXECUTOR_ERROR", 255

        # the workflow is staged but has not run yet
        if not os.path.exists(self.errfile):
            logging.info('Workflow ' + self.run_id + ': INITIALIZING')
            return "INITIALIZING", -1

        # TODO: Query with "toil status"
        completed = False
        with open(self.errfile, 'r') as f:
            for line in f:
                if 'Traceback (most recent call last)' in line:
                    logging.info('Workflow ' + self.run_id + ': EXECUTOR_ERROR')
                    open(self.staterrorfile, 'a').close()
                    return "EXECUTOR_ERROR", 255
                # run can complete successfully but fail to upload outputs to cloud buckets
                # so save the completed status and make sure there was no error elsewhere
                if 'Finished toil run successfully.' in line:
                    completed = True
        if completed:
            logging.info('Workflow ' + self.run_id + ': COMPLETE')
            open(self.statcompletefile, 'a').close()
            return "COMPLETE", 0

        logging.info('Workflow ' + self.run_id + ': RUNNING')
        return "RUNNING", -1
1231355
private void logIfJobIsCompleted(JobInstance jobInstance) {
        JobState currentState = getCurrentState(jobInstance.getId());
        if (currentState.isCompleted() && !jobInstance.isCopy()) {
            String message = String.format(
                    "State change for a completed Job is not allowed. Job %s is currently State=%s, Result=%s",
                    jobInstance.getIdentifier(), jobInstance.getState(), jobInstance.getResult());
            LOG.warn(message, new Exception().fillInStackTrace());
        }
    }
401543
def status(self):
        """"""
        # If there is no script it is either ready or a lost duplicate #
        if not self.script_path.exists:
            if self.name in     jobs.names: return "DUPLICATE"
            if self.name not in jobs.names: return "READY"
        # It is submitted already #
        if self.name in jobs.names:
            if jobs[self.name]['type'] == 'queued':  return "QUEUED"
            if jobs[self.name]['type'] == 'running': return "RUNNING"
        # So the script exists for sure but it is not in the queue #
        if not self.kwargs['out_file'].exists: return "ABORTED"
        # Let's look in log file #
        if 'CANCELED'          in self.log_tail: return "CANCELLED"
        if 'slurmstepd: error' in self.log_tail: return "CANCELLED"
        # It all looks good #
        if 'SLURM: end at'     in self.log_tail: return "FINISHED"
        # At this point we have no idea #
        return "INTERUPTED"
481940
def has_completed(self):
        """"""
        objects_in_db = WorkflowObjectModel.query.filter(
            WorkflowObjectModel.id_workflow == self.uuid,
            WorkflowObjectModel.id_parent == None,  # noqa
        ).filter(WorkflowObjectModel.status.in_([
            workflow_object_class.known_statuses.COMPLETED
        ])).count()
        return objects_in_db == len(list(self.objects))
567894
def __get_job_status(self):
        """"""
        # Figure out status and return it
        job = self.__get_job()

        if "succeeded" in job.obj["status"] and job.obj["status"]["succeeded"] > 0:
            job.scale(replicas=0)
            if self.print_pod_logs_on_exit:
                self.__print_pod_logs()
            if self.delete_on_success:
                self.__delete_job_cascade(job)
            return "SUCCEEDED"

        if "failed" in job.obj["status"]:
            failed_cnt = job.obj["status"]["failed"]
            self.__logger.debug("Kubernetes job " + self.uu_name
                                + " status.failed: " + str(failed_cnt))
            if self.print_pod_logs_on_exit:
                self.__print_pod_logs()
            if failed_cnt > self.max_retrials:
                job.scale(replicas=0)  # avoid more retrials
                return "FAILED"
        return "RUNNING"
154347
def query_job_status(self, submissionid):
        

        apiurl = '/rest/submission/'
        result = self.session.get('{}{}{}'.format(self.url, apiurl, submissionid))
        if result.status_code == 200:
            submission_info = json.loads(result.text)
            if submission_info.get('data', {}).get('submission_finished', False):  # Or something like that
                return True
        else:
            raise UnknownSubmissionIdError('Submission id seems invalid, response was not HTTP 200.')
        return False
1078551
def status(self):
        
        if self._status >= COMPLETED:
            return self._status
        else:
            cmd = self.backend.cmd_status(self, finished=False)
            response = self._run_cmd(cmd, self.remote, ignore_exit_code=True,
                                     ssh=self.ssh)
            status = self.backend.get_status(response, finished=False)
            if status is None:
                cmd = self.backend.cmd_status(self, finished=True)
                response = self._run_cmd(cmd, self.remote,
                                         ignore_exit_code=True, ssh=self.ssh)
                status = self.backend.get_status(response, finished=True)
            prev_status = self._status
            self._status = status
            if self._status not in STATUS_CODES:
                raise ValueError("Invalid status code %s", self._status)
            if prev_status != self._status:
                if self._status >= COMPLETED:
                    self.run_epilogue()
                self.dump()
            return self._status
524299
def callback(self):
    """"""
    if self.was_aborted:
      return

    mapreduce_id = self.outputs.job_id.value
    mapreduce_state = model.MapreduceState.get_by_job_id(mapreduce_id)
    if mapreduce_state.result_status != model.MapreduceState.RESULT_SUCCESS:
      self.retry("Job %s had status %s" % (
          mapreduce_id, mapreduce_state.result_status))
      return

    mapper_spec = mapreduce_state.mapreduce_spec.mapper
    outputs = []
    output_writer_class = mapper_spec.output_writer_class()
    if (output_writer_class and
        mapreduce_state.result_status == model.MapreduceState.RESULT_SUCCESS):
      outputs = output_writer_class.get_filenames(mapreduce_state)

    self.fill(self.outputs.result_status, mapreduce_state.result_status)
    self.fill(self.outputs.counters, mapreduce_state.counters_map.to_dict())
    self.complete(outputs)
632289
function status() {
  var tasks = [],
      cwd = process.cwd();

  findRepos(function(err, repos) {
    if (err) return console.log(err);
    repos.forEach(function(repo) {
      tasks.push(function(done) {
        repo.status(function(err, status) {
          if (err) return done(err);
          if (argv.b) {
            repo.branch(function(err, head) {
              if (err) return done(err);
              done(null, {status: status, head: head});
            });
          }
          else {
            done(null, {status: status});
          }
        });
      });
    });
    async.series(tasks, function(err, results) {
      if (err) return console.log(err);

      var row,
          col,
          res,
          file,
          head = [],
          table,
          symbol;

      head.push('Repo');
      if (argv.b) {
        head.push('Branch');
      }
      head.push('Status');

      table = new Table({
        head: head,
        style: {
          compact: true,
          'padding-left': 1,
          'padding-right': 1,
          head: ['white', 'bold']
        }
      });

      results.forEach(function(res) {
        var row = [];

        row.push(res.status.repo.path.replace(cwd + '/', ''));
        if (argv.b) {
          row.push(res.head.name);
        }
        row.push(res.status.clean ? 'Clean'.green : 'Changed'.red);
        table.push(row);

        if (argv.v) {
          for (var name in res.status.files) {
            row = [];
            row.push('');
            if (argv.b) {
              row.push('');
            }
            switch (res.status.files[name].type) {
              case 'A':
                symbol = '+'.green; break;
              case 'D':
                symbol = '-'.red; break;
              case 'M':
                symbol = '*'.yellow; break;
              default:
                symbol = '~'.grey; break;
            }
            row.push(' ' + symbol + ' ' + name);
            table.push(row);
          }
        }
      });

      console.log(table.toString());
    });
  });
}
168846
def status(logger):
    
    aborted = logger.get_aborted_actions()
    succeeded = logger.get_succeeded_actions()
    total = aborted + succeeded
    if total == 0:
        return 'No actions done'
    elif total == 1 and succeeded == 1:
        return 'One action done (succeeded)'
    elif total == 1 and succeeded == 0:
        return 'One action done (failed)'
    elif total == succeeded:
        return '%d actions total (all succeeded)' % total
    elif succeeded == 0:
        return '%d actions total (all failed)' % total
    else:
        msg = '%d actions total (%d failed, %d succeeded)'
        return msg % (total, aborted, succeeded)
256662
def status():
    
    import pdb; pdb.set_trace()
    branch = git.branch
    issue = jira.get_issue(branch)
    if not issue:
        return

    # Print the title
    title = issue.fields.summary
    print "(%s) %s" % (branch, title)

    # Print the status
    status = issue.fields.status.name
    assignee = issue.fields.assignee.name
    in_progress = jira.get_datetime_issue_in_progress(issue)

    if in_progress:
        in_progress_string = in_progress.strftime("%a %x %I:%M %p")
        print '  Status: %s as of %s' % (status, in_progress_string)
    else:
        print '  Status: %s' % status

    print '  Assignee: %s' % assignee

    # Print the worklogs

    # Get the timespent and return 0m if it does not exist
    time_spent = '0m'
    try:
        time_spent = issue.fields.timetracking.timeSpent
    except:
        pass

    worklogs = jira.get_worklog(issue)
    print "\nTime logged (%s):" % time_spent
    if worklogs:
        for worklog in worklogs:
            worklog_hash = worklog.raw

            author = worklog_hash['author']['name']

            time_spent = worklog_hash.get('timeSpent', '0m')

            created = dateutil.parser.parse(worklog_hash['started'])
            created_pattern = '%a %x         '  # Adding extra space for formatting
            if not created.hour == created.minute == created.second == 0:
                created = created.astimezone(tzlocal())
                created_pattern = '%a %x %I:%M %p'
            comment = worklog_hash.get('comment', '<no comment>')

            updated_string = created.strftime(created_pattern)
            print "  %s - %s (%s): %s" % (updated_string, author, time_spent, comment)
    else:
        print "  No worklogs"

    cycle_time = jira.get_cycle_time(issue)
    if cycle_time:
        print '\nCycle Time: %.1f days' % cycle_time

    # Print the time elapsed since the last mark
    elapsed_time = jira.get_elapsed_time(issue)
    if elapsed_time:
        print '\n\033[0;32m%s elapsed\033[00m (use "jtime log ." to log elapsed time or "jtime log <duration> (ex. 30m, 1h etc.)" to log a specific amount of time)' % (elapsed_time)
    else:
        print '\n\033[0;32m0m elapsed\033[00m'
700986
def mark_job_as_completed(job_id, data=None):
    
    update_dict = {
        "status": "complete",
        "data": json.dumps(data),
        "finished_timestamp": datetime.datetime.now(),
    }
    _update_job(job_id, update_dict)
926822
def getPIDStatus(jobStoreName):
        
        try:
            jobstore = Toil.resumeJobStore(jobStoreName)
        except NoSuchJobStoreException:
            return 'QUEUED'
        except NoSuchFileException:
            return 'QUEUED'

        try:
            with jobstore.readSharedFileStream('pid.log') as pidFile:
                pid = int(pidFile.read())
                try:
                    os.kill(pid, 0)  # Does not kill process when 0 is passed.
                except OSError:  # Process not found, must be done.
                    return 'COMPLETED'
                else:
                    return 'RUNNING'
        except NoSuchFileException:
            pass
        return 'QUEUED'
466474
def check_job(cls, job_details):
        
        return check_log(job_details.logfile, cls.string_exited, cls.string_successful)