Exemplo n.º 1
0
def add_log(task_id: ObjectId, task_type: str, user: dict):
    task_cls = tasks_cls_for(task_type)
    task = task_cls().get(task_id)
    if task is None:
        raise errors.NotFound()

    request_json = request.get_json()

    task_cls.update_logs(
        task_id,
        worker_log=request_json.get("worker_log"),
        installer_log=request_json.get("installer_log"),
        uploader_log=request_json.get("uploader_log"),
        downloader_log=request_json.get("downloader_log"),
        wipe_log=request_json.get("wipe_log"),
        writer_log=request_json.get("writer_log"),
    )

    # update ACK
    Acknowlegments.busy_update(
        username=user["username"],
        worker_type=task_type,
        slot=request.args.get("slot"),
        task_id=task_id,
    )

    return jsonify({"_id": task_id})
Exemplo n.º 2
0
def register_task(task_id: ObjectId, task_type: str, user: dict):
    task_cls = tasks_cls_for(task_type)
    task = task_cls().find({"_id": task_id, "status": task_cls.pending})
    if task is None:
        raise errors.NotFound()

    task_cls.register(task_id, user)

    # update ACK
    Acknowlegments.busy_update(
        username=user["username"],
        worker_type=task_type,
        slot=request.args.get("slot"),
        task_id=task_id,
    )

    return jsonify({"_id": task_id})