Return all job data from all returners
557206
def get_jids():
    '''
    
    '''
    ret = {}
    for returner_ in __opts__[CONFIG_KEY]:
        ret.update(_mminion().returners['{0}.get_jids'.format(returner_)]())

    return ret
923549
def term_all_jobs():
    '''
    
    '''
    ret = []
    for data in running():
        ret.append(signal_job(data['jid'], signal.SIGTERM))
    return ret
2320
def returner(ret):
    '''
    
    '''
    # if a minion is returning a standalone job, get a jobid
    if ret['jid'] == 'req':
        ret['jid'] = prep_jid(nocache=ret.get('nocache', False))
        save_load(ret['jid'], ret)

    try:
        with _get_serv(ret, commit=True) as cur:
            sql = '''INSERT INTO `salt_returns`
                     (`fun`, `jid`, `return`, `id`, `success`, `full_ret`)
                     VALUES (%s, %s, %s, %s, %s, %s)'''

            cur.execute(sql, (ret['fun'], ret['jid'],
                              salt.utils.json.dumps(ret['return']),
                              ret['id'],
                              ret.get('success', False),
                              salt.utils.json.dumps(ret)))
    except salt.exceptions.SaltMasterError as exc:
        log.critical(exc)
        log.critical('Could not store return with MySQL returner. MySQL server unavailable.')
570828
def list(self, argv):
        """"""

        def read(job):
            for key in sorted(job.content.keys()):
                # Ignore some fields that make the output hard to read and
                # that are available via other commands.
                if key in ["performance"]: continue
                print("%s: %s" % (key, job.content[key]))

        if len(argv) == 0:
            index = 0
            for job in self.service.jobs:
                print("@%d : %s" % (index, job.sid))
                index += 1
            return

        self.foreach(argv, read)
414879
def jobs(self):
        
        if self._jobs is None:
            self._jobs = JobTable(self.connection, self.database)
        return self._jobs
267312
def all_jobs(self):
        
        return list(set(self.complete + self.failed + self.queue + self.running))
1107713
def job_result(project_id, job_id, opts = {})
      data, _status_code, _headers = job_result_with_http_info(project_id, job_id, opts)
      return data
    end
783567
def get_jobs(self, recursive=True):
        
        if recursive:
            ret_dict = self.jobs.copy()
            ret_dict.update(self._scatter_link.get_jobs(recursive))
            return ret_dict
        return self.jobs
532435
def communicate(self, job_ids = None):
    """"""
    self.lock()
    # iterate over all jobs
    jobs = self.get_jobs(job_ids)
    for job in jobs:
      job.refresh()
      if job.status in ('queued', 'executing', 'waiting') and job.queue_name != 'local':
        status = qstat(job.id, context=self.context)
        if len(status) == 0:
          job.status = 'failure'
          job.result = 70 # ASCII: 'F'
          logger.warn("The job '%s' was not executed successfully (maybe a time-out happened). Please check the log files." % job)
          for array_job in job.array:
            if array_job.status in ('queued', 'executing'):
              array_job.status = 'failure'
              array_job.result = 70 # ASCII: 'F'


    self.session.commit()
    self.unlock()
353653
def serialize_job(job):
    """"""
    d = dict(
        id=job.get_id(),
        uri=url_for('jobs.get_job', job_id=job.get_id(), _external=True),
        status=job.get_status(),
        result=job.result
    )
    return d
253527
def cache_job(self, jid, id_, ret, fun):
        '''
        
        '''
        self.returners['{0}.returner'.format(self.opts['master_job_cache'])]({'jid': jid,
                                                                              'id': id_,
                                                                              'return': ret,
                                                                              'fun': fun})
1324733
def get_jobs(self, recursive=True):
        
        if recursive:
            ret_dict = self.jobs.copy()
            return ret_dict
        return self.jobs
1159851
def dump_all_outputs(self, job, target, abspaths=None):
        
        import os
        import shutil
        from pathlib import Path

        root = Path(native_str(target))
        true_outputs = job.get_output()

        if abspaths or len(true_outputs) < self.BULK_OUTPUT_FILE_THRESHOLD:
            return super().dump_all_outputs(job, root, abspaths)

        stagingdir = root / Path(native_str(job.workingdir)).name
        workdir = job.get_directory(job.workingdir)
        if not root.is_dir():
            root.mkdir(parents=False)
        if stagingdir.exists():
            if PY2:
                raise IOError('Path % exists' % stagingdir)
            else:
                raise FileExistsError(stagingdir)
        workdir.put(str(root))
        assert stagingdir.is_dir()
        assert root in stagingdir.parents

        for pathstr in true_outputs:
            if os.path.isabs(pathstr):
                continue
            destpath = root / pathstr
            currpath = stagingdir / pathstr
            if not destpath.parent.is_dir():
                destpath.parent.mkdir(parents=True)
            currpath.rename(destpath)

        shutil.rmtree(str(stagingdir))
702739
def dump_all_outputs(self, job, target, abspaths=None):
        
        from pathlib import Path
        root = Path(native_str(target))

        for outputpath, outputfile in job.get_output().items():
            path = Path(native_str(outputpath))

            # redirect absolute paths into the appropriate subdirectory
            if path.is_absolute():
                if abspaths:
                    path = Path(native_str(abspaths), *path.parts[1:])
                else:
                    continue

            dest = root / path
            if not dest.parent.is_dir():
                dest.parent.mkdir(parents=True)
            if dest.is_file():
                dest.unlink()
            try:
                outputfile.put(str(dest))
            except IsADirectoryError:
                if not dest.is_dir():
                    dest.mkdir(parents=True)
1062737
def job(project_id, job_id, opts = {})
      data, _status_code, _headers = job_with_http_info(project_id, job_id, opts)
      return data
    end
1292442
def ReadCronJobRuns(self, job_id):
    """"""
    runs = [
        run for run in itervalues(self.cronjob_runs)
        if run.cron_job_id == job_id
    ]
    return sorted(runs, key=lambda run: run.started_at, reverse=True)
1095188
def get_all(self, collection_name, since=None):
        
        if since is None:
            query = {}
        else:
            query = {job.TIMEPERIOD: {'$gte': since}}
        collection = self.ds.connection(collection_name)

        cursor = collection.find(query)
        if cursor.count() == 0:
            raise LookupError('MongoDB has no job records in collection {0} since {1}'.format(collection_name, since))
        return [Job.from_json(document) for document in cursor]