2022-08-02 19:50:16 +00:00
|
|
|
import time
|
2022-08-12 21:29:18 +00:00
|
|
|
from selfprivacy_api.utils.huey import huey
|
2022-08-02 19:50:16 +00:00
|
|
|
from selfprivacy_api.jobs import JobStatus, Jobs
|
|
|
|
|
|
|
|
|
|
|
|
@huey.task()
|
|
|
|
def test_job():
|
2022-08-02 20:30:03 +00:00
|
|
|
job = Jobs.get_instance().add(
|
2022-08-02 19:50:16 +00:00
|
|
|
name="Test job",
|
|
|
|
description="This is a test job.",
|
|
|
|
status=JobStatus.CREATED,
|
|
|
|
status_text="",
|
|
|
|
progress=0,
|
|
|
|
)
|
|
|
|
time.sleep(5)
|
2022-08-02 20:30:03 +00:00
|
|
|
Jobs.get_instance().update(
|
2022-08-02 19:50:16 +00:00
|
|
|
job=job,
|
|
|
|
status=JobStatus.RUNNING,
|
|
|
|
status_text="Performing pre-move checks...",
|
|
|
|
progress=5,
|
|
|
|
)
|
|
|
|
time.sleep(5)
|
2022-08-02 20:30:03 +00:00
|
|
|
Jobs.get_instance().update(
|
2022-08-02 19:50:16 +00:00
|
|
|
job=job,
|
|
|
|
status=JobStatus.RUNNING,
|
|
|
|
status_text="Performing pre-move checks...",
|
|
|
|
progress=10,
|
|
|
|
)
|
|
|
|
time.sleep(5)
|
2022-08-02 20:30:03 +00:00
|
|
|
Jobs.get_instance().update(
|
2022-08-02 19:50:16 +00:00
|
|
|
job=job,
|
|
|
|
status=JobStatus.RUNNING,
|
|
|
|
status_text="Performing pre-move checks...",
|
|
|
|
progress=15,
|
|
|
|
)
|
|
|
|
time.sleep(5)
|
2022-08-02 20:30:03 +00:00
|
|
|
Jobs.get_instance().update(
|
2022-08-02 19:50:16 +00:00
|
|
|
job=job,
|
|
|
|
status=JobStatus.RUNNING,
|
|
|
|
status_text="Performing pre-move checks...",
|
|
|
|
progress=20,
|
|
|
|
)
|
|
|
|
time.sleep(5)
|
2022-08-02 20:30:03 +00:00
|
|
|
Jobs.get_instance().update(
|
2022-08-02 19:50:16 +00:00
|
|
|
job=job,
|
|
|
|
status=JobStatus.RUNNING,
|
|
|
|
status_text="Performing pre-move checks...",
|
|
|
|
progress=25,
|
|
|
|
)
|
|
|
|
time.sleep(5)
|
2022-08-02 20:30:03 +00:00
|
|
|
Jobs.get_instance().update(
|
2022-08-02 19:50:16 +00:00
|
|
|
job=job,
|
|
|
|
status=JobStatus.FINISHED,
|
|
|
|
status_text="Job finished.",
|
|
|
|
progress=100,
|
|
|
|
)
|