]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - src/web/handlers_jobs.py
5 from .handlers_base
import BaseHandler
7 class JobsIndexHandler(BaseHandler
):
9 # Filter for a certain arch.
10 arch
= self
.get_argument("arch", None)
11 if not arch
or not self
.backend
.arches
.exists(arch
):
12 raise tornado
.web
.HTTPError(400, "Architecture does not exist")
14 # Check if we need to filter for a certain builder.
15 builder_name
= self
.get_argument("builder", None)
17 builder
= self
.pakfire
.builders
.get_by_name(builder_name
)
21 # Filter for a certain date.
22 date
= self
.get_argument("date", None)
24 # Get all jobs, that fulfill the criteria.
25 jobs
= self
.pakfire
.jobs
.get_latest(limit
=50, arch
=arch
, builder
=builder
,
28 self
.render("jobs-index.html", jobs
=jobs
, arch
=arch
, builder
=builder
,
32 class JobsFilterHandler(BaseHandler
):
34 builders
= self
.pakfire
.builders
.get_all()
36 self
.render("jobs-filter.html", arches
=self
.backend
.arches
, builders
=builders
)
39 class JobDetailHandler(BaseHandler
):
41 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
43 raise tornado
.web
.HTTPError(404, "No such job: %s" % job
)
48 self
.render("jobs-detail.html", job
=job
, build
=job
.build
, log
=log
)
51 class JobBuildrootHandler(BaseHandler
):
53 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
55 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
57 # Calculate the download size and buildroot size.
61 for name
, uuid
, pkg
in job
.buildroot
:
65 download_size
+= pkg
.filesize
66 buildroot_size
+= pkg
.size
68 self
.render("jobs-buildroot.html", job
=job
, build
=job
.build
,
69 buildroot
=job
.buildroot
, download_size
=download_size
,
70 buildroot_size
=buildroot_size
)
73 class JobScheduleHandler(BaseHandler
):
74 allowed_types
= ("test", "rebuild",)
76 @tornado.web
.authenticated
78 type = self
.get_argument("type")
79 assert type in self
.allowed_types
81 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
83 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
85 self
.render("job-schedule-%s.html" % type, type=type, job
=job
, build
=job
.build
)
87 @tornado.web
.authenticated
89 type = self
.get_argument("type")
90 assert type in self
.allowed_types
92 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
94 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
96 # Get the start offset.
97 offset
= self
.get_argument("offset", 0)
105 job
= job
.schedule_test(offset
)
107 elif type == "rebuild":
108 job
.schedule_rebuild(offset
)
110 self
.redirect("/job/%s" % job
.uuid
)
113 class JobAbortHandler(BaseHandler
):
114 def get_job(self
, uuid
):
115 job
= self
.pakfire
.jobs
.get_by_uuid(uuid
)
117 raise tornado
.web
.HTTPError(404, "Job not found: %s" % uuid
)
121 @tornado.web
.authenticated
123 job
= self
.get_job(uuid
)
125 # XXX Check if user has the right to manage the job.
127 self
.render("jobs-abort.html", job
=job
)
129 @tornado.web
.authenticated
130 def post(self
, uuid
):
131 job
= self
.get_job(uuid
)
133 # XXX Check if user has the right to manage the job.
135 # Only running builds can be set to aborted state.
136 if not job
.state
== "running":
137 # XXX send the user a nicer error message.
138 self
.redirect("/job/%s" % job
.uuid
)
141 # Set the job into aborted state.
142 job
.state
= "aborted"
144 # 0 means the job was aborted by the user.
145 job
.aborted_state
= 0
147 self
.redirect("/job/%s" % job
.uuid
)