]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - src/web/jobs.py
defdefbaf5f2ec22a3766485b2509d5e0e1d7047
7 class ShowQueueHandler(base
.BaseHandler
):
8 def get(self
, arch
=None):
10 if not self
.backend
.arches
.exists(arch
):
11 raise tornado
.web
.HTTPError(400, "Architecture does not exist")
13 queue
= self
.backend
.jobqueue
.for_arches([arch
, "noarch"])
15 queue
= self
.backend
.jobqueue
17 self
.render("queue.html", arch
=arch
, queue
=queue
)
20 class JobDetailHandler(base
.BaseHandler
):
22 job
= self
.backend
.jobs
.get_by_uuid(uuid
)
24 raise tornado
.web
.HTTPError(404, "No such job: %s" % job
)
29 self
.render("jobs-detail.html", job
=job
, build
=job
.build
, log
=log
)
32 class JobBuildrootHandler(base
.BaseHandler
):
34 job
= self
.backend
.jobs
.get_by_uuid(uuid
)
36 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
38 # Calculate the download size and buildroot size.
42 for name
, uuid
, pkg
in job
.buildroot
:
46 download_size
+= pkg
.filesize
47 buildroot_size
+= pkg
.size
49 self
.render("jobs-buildroot.html", job
=job
, build
=job
.build
,
50 buildroot
=job
.buildroot
, download_size
=download_size
,
51 buildroot_size
=buildroot_size
)
54 class JobScheduleHandler(base
.BaseHandler
):
55 allowed_types
= ("test", "rebuild",)
57 @tornado.web
.authenticated
59 type = self
.get_argument("type")
60 assert type in self
.allowed_types
62 job
= self
.backend
.jobs
.get_by_uuid(uuid
)
64 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
66 self
.render("job-schedule-%s.html" % type, type=type, job
=job
, build
=job
.build
)
68 @tornado.web
.authenticated
70 type = self
.get_argument("type")
71 assert type in self
.allowed_types
73 job
= self
.backend
.jobs
.get_by_uuid(uuid
)
75 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
77 # Get the start offset.
78 offset
= self
.get_argument("offset", 0)
86 job
= job
.schedule_test(offset
)
88 elif type == "rebuild":
89 job
.schedule_rebuild(offset
)
91 self
.redirect("/job/%s" % job
.uuid
)
94 class JobAbortHandler(base
.BaseHandler
):
95 def get_job(self
, uuid
):
96 job
= self
.backend
.jobs
.get_by_uuid(uuid
)
98 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
102 @tornado.web
.authenticated
104 job
= self
.get_job(uuid
)
106 # XXX Check if user has the right to manage the job.
108 self
.render("jobs-abort.html", job
=job
)
110 @tornado.web
.authenticated
111 def post(self
, uuid
):
112 job
= self
.get_job(uuid
)
114 # XXX Check if user has the right to manage the job.
116 # Only running builds can be set to aborted state.
117 if not job
.state
== "running":
118 # XXX send the user a nicer error message.
119 self
.redirect("/job/%s" % job
.uuid
)
122 # Set the job into aborted state.
123 job
.state
= "aborted"
125 # 0 means the job was aborted by the user.
126 job
.aborted_state
= 0
128 self
.redirect("/job/%s" % job
.uuid
)