Exemplo n.º 1
0
def save_job_info(job_id, **kwargs):
    job_info = JobInfo()
    job_info.job_id = job_id
    job_info.create_date = datetime.datetime.now()
    for k, v in kwargs.items():
        setattr(job_info, k, v)
    job_info.save(force_insert=True)
Exemplo n.º 2
0
def set_job_failed(job_id, role, party_id):
    sql = JobInfo.update(status='failed').where(JobInfo.job_id == job_id,
                                                JobInfo.role == role,
                                                JobInfo.party_id == party_id,
                                                JobInfo.status != 'success')
    return sql.execute() > 0
Exemplo n.º 3
0
def save_job_info(job_id, role, party_id, save_info, create=False):
    jobs = JobInfo.select().where(JobInfo.job_id == job_id,
                                  JobInfo.role == role,
                                  JobInfo.party_id == party_id)
    is_insert = True
    if jobs:
        job_info = jobs[0]
        is_insert = False
    elif create:
        job_info = JobInfo()
    else:
        return None
    job_info.job_id = job_id
    job_info.role = role
    job_info.party_id = party_id
    job_info.create_date = datetime.datetime.now()
    for k, v in save_info.items():
        if k in ['job_id', 'role', 'party_id']:
            continue
        setattr(job_info, k, v)
    if is_insert:
        job_info.save(force_insert=True)
    else:
        job_info.save()
    return job_info
Exemplo n.º 4
0
def query_job_by_id(job_id):
    jobs = JobInfo.select().where(JobInfo.job_id == job_id)
    return jobs
def save_job_info(job_id, role, party_id, save_info, create=False):
    jobs = JobInfo.select().where(JobInfo.job_id == job_id, JobInfo.role == role, JobInfo.party_id == party_id)
    is_insert = True
    if jobs:
        job_info = jobs[0]
        is_insert = False
    elif create:
        job_info = JobInfo()
    else:
        return None
    job_info.job_id = job_id
    job_info.role = role
    job_info.party_id = party_id
    job_info.create_date = datetime.datetime.now()
    if 'status' in save_info:
        if job_info.status in ['success', 'failed', 'partial', 'deleted']:
            # Termination status cannot be updated
            save_info.pop('status')
    for k, v in save_info.items():
        if k in ['job_id', 'role', 'party_id']:
            continue
        setattr(job_info, k, v)
    if is_insert:
        job_info.save(force_insert=True)
    else:
        job_info.save()
    return job_info
Exemplo n.º 6
0
def update_job_by_id(job_id, update_data):
    sql = JobInfo.update(**update_data).where(JobInfo.job_id == job_id)
    return sql.execute() > 0
Exemplo n.º 7
0
def query_job_by_id(job_id):
    jobs = JobInfo.select().where(JobInfo.job_id == job_id)
    return [job.to_json() for job in jobs]