mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
28 lines
689 B
Python
28 lines
689 B
Python
from .. import db
|
|
from ..decorators import background
|
|
from ..models import Job
|
|
|
|
|
|
@background
|
|
def delete_job(job_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
job = Job.query.get(job_id)
|
|
if job is None:
|
|
raise Exception('Job {} not found'.format(job_id))
|
|
job.delete()
|
|
db.session.commit()
|
|
|
|
|
|
@background
|
|
def restart_job(job_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
job = Job.query.get(job_id)
|
|
if job is None:
|
|
raise Exception('Job {} not found'.format(job_id))
|
|
try:
|
|
job.restart()
|
|
except Exception:
|
|
pass
|
|
else:
|
|
db.session.commit()
|