示例#1
0
def _handle_job(mode: str, pk: str, json_body: dict,
                session: Session) -> DBRes:
    handle_name = 'handle_' + mode

    if mode in JobControlHandle and handle_name in JobControlHandle:
        if pk.isdigit():
            transform = DBDao.get_transform(pk, session=session)
            if transform is None:
                return DBRes.api_error(msg='job id {} not found!!!'.format(pk))
        else:
            transform = pk
        data = json_body
        run_res = getattr(JobControlHandle, handle_name)(transform, **data)
        return DBRes(code=500 if run_res.startswith(FAIL_HEADER) else 200,
                     msg=run_res)
    else:
        return DBRes.api_error(msg=' {} not support!!!'.format(mode))
示例#2
0
 def _get():
     job_infos = defaultdict(dict)
     for x in DBDao.get_transform():
         name = "{}_{}".format(x.id, x.name)
         job_infos[name] = x.to_dict()
     return job_infos