Generate jenkins job details.
426549
def jenkins(self):
        """"""
        job_name = self.format['jenkins_job_name'].format(**self.data)
        job = {'name': job_name}

        return job
1183250
protected Map<String, String> runningDetailsFor(final JobInfo jobInfo) {
        final Map<String, String> details = new HashMap<>();
        details.put("Started", ISO_DATE_TIME.format(jobInfo.getStarted()));
        if (jobInfo.getStopped().isPresent()) {
            details.put("Stopped", ISO_DATE_TIME.format(jobInfo.getStopped().get()));
        }
        return details;
    }
466474
def check_job(cls, job_details):
        
        return check_log(job_details.logfile, cls.string_exited, cls.string_successful)
381408
def register_jobs(self, job_dict):
        """"""
        njobs = len(job_dict)
        sys.stdout.write("Registering %i total jobs: " % njobs)
        for i, job_details in enumerate(job_dict.values()):
            if i % 10 == 0:
                sys.stdout.write('.')
                sys.stdout.flush()
            self.register_job(job_details)
        sys.stdout.write('!\n')
1255532
def dispatch_job(jobname, exe, args, opts, batch_opts, dry_run=True):
    

    batch_opts.setdefault('W', 300)
    batch_opts.setdefault('R', 'rhel60 && scratch > 10')

    cmd_opts = ''
    for k, v in opts.items():

        if isinstance(v, list):
            cmd_opts += ' '.join(['--%s=%s' % (k, t) for t in v])
        elif isinstance(v, bool) and v:
            cmd_opts += ' --%s ' % (k)
        elif isinstance(v, bool):
            continue
        elif v is not None:
            cmd_opts += ' --%s=\"%s\" ' % (k, v)

    bash_script = "{exe} {args} {opts}"
    scriptexe = jobname + '.sh'
    with open(os.path.join(scriptexe), 'wt') as f:
        f.write(bash_script.format(exe=exe, args=' '.join(args),
                                   opts=cmd_opts))

    batch_optstr = parse_lsf_opts(**batch_opts)
    batch_cmd = 'bsub %s ' % (batch_optstr)
    batch_cmd += ' bash %s' % scriptexe
    print(batch_cmd)
    if not dry_run:
        os.system(batch_cmd)
171985
def job_data(cls, job_id=dummy_job_id, branches=None, **kwargs):
        
        return dict(job_id=job_id, branches=branches or [])
1181845
def job_to_dict(job):
    """"""

    data = OrderedDict()
    data['id'] = job.id
    data['name'] = job.name
    data['func'] = job.func_ref
    data['args'] = job.args
    data['kwargs'] = job.kwargs

    data.update(trigger_to_dict(job.trigger))

    if not job.pending:
        data['misfire_grace_time'] = job.misfire_grace_time
        data['max_instances'] = job.max_instances
        data['next_run_time'] = None if job.next_run_time is None else job.next_run_time

    return data
753428
def build_job_configs(self, args):
        
        job_configs = {}

        gmm = make_ring_dicts(library=args['library'], basedir='.')

        for galkey in gmm.galkeys():
            ring_dict = gmm.ring_dict(galkey)
            for ring_key, ring_info in ring_dict.items():
                output_file = ring_info.merged_gasmap
                file_string = ""
                for fname in ring_info.files:
                    file_string += " %s" % fname
                logfile = make_nfs_path(output_file.replace('.fits', '.log'))
                job_configs[ring_key] = dict(output=output_file,
                                             args=file_string,
                                             logfile=logfile)

        return job_configs
247840
def _get_logs(job_id):
    """"""
    # Avoid SQLAlchemy "Unicode type received non-unicode bind param value"
    # warnings.
    job_id = unicode(job_id)

    results = ENGINE.execute(
        LOGS_TABLE.select().where(LOGS_TABLE.c.job_id == job_id)).fetchall()

    results = [dict(result) for result in results]

    for result in results:
        result.pop("job_id")

    return results
832532
def build_job_configs(self, args):
        
        job_configs = {}

        ttype = args['ttype']
        (sim_targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args)
        targets = load_yaml(sim_targets_yaml)

        base_config = dict(ttype=ttype,
                           roi_baseline=args['roi_baseline'],
                           extracopy = args['extracopy'],
                           sim=sim)

        for target_name in targets.keys():
            targetdir = NAME_FACTORY.sim_targetdir(target_type=ttype,
                                                   target_name=target_name,
                                                   sim_name=sim)
            logfile = os.path.join(targetdir, 'copy_base_dir.log')
            job_config = base_config.copy()
            job_config.update(dict(target=target_name,
                                   logfile=logfile))
            job_configs[target_name] = job_config

        return job_configs
1256685
def job_details(job_id, connection=None):
    """"""
    if connection is None:
        connection = r
    data = connection.hgetall(job_key(job_id))

    job_data = {'id': job_id, 'schedule_at': int(connection.zscore(REDIS_KEY,
                                                                   job_id))}
    for key, value in data.items():
        try:
            decoded = value.decode('utf-8')
        except UnicodeDecodeError:
            decoded = value
        if decoded.isdigit():
            decoded = int(decoded)
        job_data[key.decode('utf-8')] = decoded
    return job_data
365079
def yaml_to_job_list(yaml_file, base_dir):
    """"""
    yaml_dict = get_yaml_dict(yaml_file)
    job_list = []
    for key, value in yaml_dict.items():
        job_list.append((value, rel_to_cwd(base_dir, key)))

    return job_list
961071
def _run_tool(job_name, t, fastafile, params):
    """"""
    try:
        result = t.run(fastafile, params, mytmpdir())
    except Exception as e:
        result = ([], "", "{} failed to run: {}".format(job_name, e))
    
    return job_name, result
922779
def gen_job(
        script,
        job_name,
        log_path='qlogs',
        group='km3net',
        platform='cl7',
        walltime='00:10:00',
        vmem='8G',
        fsize='8G',
        shell=None,
        email=None,
        send_mail='n',
        job_array_start=1,
        job_array_stop=None,
        job_array_step=1,
        irods=False,
        sps=True,
        hpss=False,
        xrootd=False,
        dcache=False,
        oracle=False,
        split_array_logs=False
):
    """"""
    if shell is None:
        shell = os.environ['SHELL']
    if email is None:
        email = os.environ['USER'] + '@km3net.de'
    if isinstance(script, Script):
        script = str(script)
    log_path = os.path.join(os.getcwd(), log_path)
    if job_array_stop is not None:
        job_array_option = "#$ -t {}-{}:{}"  \
                           .format(job_array_start, job_array_stop,
                                   job_array_step)
    else:
        job_array_option = "#"
    if split_array_logs:
        task_name = '_$TASK_ID'
    else:
        task_name = ''
    job_string = JOB_TEMPLATE.format(
        script=script,
        email=email,
        send_mail=send_mail,
        log_path=log_path,
        job_name=job_name,
        group=group,
        walltime=walltime,
        vmem=vmem,
        fsize=fsize,
        irods=irods,
        sps=sps,
        hpss=hpss,
        xrootd=xrootd,
        dcache=dcache,
        oracle=oracle,
        shell=shell,
        platform=platform,
        job_array_option=job_array_option,
        task_name=task_name
    )
    return job_string
709207
def present(name,
            config=None,
            **kwargs):
    '''
    
    '''

    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ['Job {0} is up to date.'.format(name)]}

    if __salt__['jenkins.job_exists'](name):
        _current_job_config = __salt__['jenkins.get_job_config'](name)
        buf = six.moves.StringIO(_current_job_config)
        oldXML = ET.fromstring(buf.read())

        cached_source_path = __salt__['cp.cache_file'](config, __env__)
        with salt.utils.files.fopen(cached_source_path) as _fp:
            newXML = ET.fromstring(salt.utils.stringutils.to_unicode(_fp.read()))
        if not _elements_equal(oldXML, newXML):
            diff = difflib.unified_diff(
                ET.tostringlist(oldXML, encoding='utf8', method='xml'),
                ET.tostringlist(newXML, encoding='utf8', method='xml'), lineterm='')
            try:
                __salt__['jenkins.update_job'](name, config, __env__)
            except CommandExecutionError as exc:
                return _fail(ret, exc.strerror)
            else:
                ret['changes'] = ''.join(diff)
                ret['comment'].append('Job \'{0}\' updated.'.format(name))

    else:
        cached_source_path = __salt__['cp.cache_file'](config, __env__)
        with salt.utils.files.fopen(cached_source_path) as _fp:
            new_config_xml = salt.utils.stringutils.to_unicode(_fp.read())

        try:
            __salt__['jenkins.create_job'](name, config, __env__)
        except CommandExecutionError as exc:
            return _fail(ret, exc.strerror)

        buf = six.moves.StringIO(new_config_xml)
        diff = difflib.unified_diff('', buf.readlines(), lineterm='')
        ret['changes'][name] = ''.join(diff)
        ret['comment'].append('Job \'{0}\' added.'.format(name))

    ret['comment'] = '\n'.join(ret['comment'])
    return ret
250911
def _serialize(self, include_run_logs=False, strict_json=False):
        
        result = {'dagobah_id': self.dagobah_id,
                  'created_jobs': self.created_jobs,
                  'jobs': [job._serialize(include_run_logs=include_run_logs,
                                          strict_json=strict_json)
                           for job in self.jobs]}
        if strict_json:
            result = json.loads(json.dumps(result, cls=StrictJSONEncoder))
        return result
853869
def prefix_search(self, job_name_prefix):
        """"""
        json = self._fetch_json()
        jobs = json['response']
        for job in jobs:
            if job.startswith(job_name_prefix):
                yield self._build_results(jobs, job)