]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - web/handlers_jobs.py
5 from handlers_base
import BaseHandler
8 class JobsIndexHandler(BaseHandler
):
10 # Filter for a certain arch.
11 arch_name
= self
.get_argument("arch", None)
13 arch
= self
.pakfire
.arches
.get_by_name(arch_name
)
17 # Check if we need to filter for a certain builder.
18 builder_name
= self
.get_argument("builder", None)
20 builder
= self
.pakfire
.builders
.get_by_name(builder_name
)
24 # Filter for a certain date.
25 date
= self
.get_argument("date", None)
27 # Get all jobs, that fulfill the criteria.
28 jobs
= self
.pakfire
.jobs
.get_latest(limit
=50, arch
=arch
, builder
=builder
,
31 self
.render("jobs-index.html", jobs
=jobs
, arch
=arch
, builder
=builder
,
35 class JobsFilterHandler(BaseHandler
):
37 arches
= self
.pakfire
.arches
.get_all(really
=True)
38 builders
= self
.pakfire
.builders
.get_all()
40 self
.render("jobs-filter.html", arches
=arches
, builders
=builders
)
43 class JobDetailHandler(BaseHandler
):
45 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
47 raise tornado
.web
.HTTPError(404, "No such job: %s" % job
)
52 self
.render("jobs-detail.html", job
=job
, build
=job
.build
, log
=log
)
55 class JobBuildrootHandler(BaseHandler
):
57 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
59 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
61 tries
= self
.get_argument("tries", None)
62 buildroot
= job
.get_buildroot(tries
)
64 # Calculate the download size and buildroot size.
68 for name
, uuid
, pkg
in buildroot
:
72 download_size
+= pkg
.filesize
73 buildroot_size
+= pkg
.size
75 self
.render("jobs-buildroot.html", job
=job
, build
=job
.build
,
76 buildroot
=buildroot
, download_size
=download_size
,
77 buildroot_size
=buildroot_size
)
80 class JobScheduleHandler(BaseHandler
):
81 allowed_types
= ("test", "rebuild",)
83 @tornado.web
.authenticated
85 type = self
.get_argument("type")
86 assert type in self
.allowed_types
88 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
90 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
92 self
.render("job-schedule-%s.html" % type, type=type, job
=job
, build
=job
.build
)
94 @tornado.web
.authenticated
96 type = self
.get_argument("type")
97 assert type in self
.allowed_types
99 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
101 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
103 # Get the start offset.
104 offset
= self
.get_argument("offset", 0)
112 job
= job
.schedule_test(offset
)
114 elif type == "rebuild":
115 job
.schedule_rebuild(offset
)
117 self
.redirect("/job/%s" % job
.uuid
)
120 class JobAbortHandler(BaseHandler
):
121 def get_job(self
, uuid
):
122 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
124 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
128 @tornado.web
.authenticated
130 job
= self
.get_job(uuid
)
132 # XXX Check if user has the right to manage the job.
134 self
.render("jobs-abort.html", job
=job
)
136 @tornado.web
.authenticated
137 def post(self
, uuid
):
138 job
= self
.get_job(uuid
)
140 # XXX Check if user has the right to manage the job.
142 # Only running builds can be set to aborted state.
143 if not job
.state
== "running":
144 # XXX send the user a nicer error message.
145 self
.redirect("/job/%s" % job
.uuid
)
148 # Set the job into aborted state.
149 job
.state
= "aborted"
151 # 0 means the job was aborted by the user.
152 job
.aborted_state
= 0
154 self
.redirect("/job/%s" % job
.uuid
)