(r"/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/abort", jobs.AbortHandler),
(r"/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/log", jobs.LogHandler),
(r"/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/retry", jobs.RetryHandler),
- (r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", jobs.APIv1IndexHandler),
(r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/crashed",
jobs.APIv1CrashedHandler),
+ (r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/finished",
+ jobs.APIv1FinishedHandler),
(r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/log/stream",
jobs.APIv1LogStreamHandler),
# Setup logging
log = logging.getLogger("pbs.web.jobs")
-class APIv1IndexHandler(base.APIMixin, tornado.web.RequestHandler):
+class APIv1FinishedHandler(base.APIMixin, base.BackendMixin, tornado.web.RequestHandler):
@base.negotiate
async def post(self, uuid):
job = await self.backend.jobs.get_by_uuid(uuid)
# Check permissions
if not job.has_perm(self.current_user):
- raise tornado.web.HTTPError(403, "%s cannot edit job %s" % (self.current_user, job))
+ raise tornado.web.HTTPError(403)
# Success Status
success = self.get_argument_bool("success")
# Fetch the logfile
- logfile = self.get_argument_upload("logfile")
+ logfile = await self.get_argument_upload("logfile")
# Fetch the packages
- packages = self.get_argument_uploads("packages")
+ packages = await self.get_argument_uploads("packages")
# Mark the job as finished
- with self.db.transaction():
- builds = await job.finished(success=success,
- logfile=logfile, packages=packages)
+ async with await self.db.transaction():
+ builds = await job.finished(
+ success = success,
+ logfile = logfile,
+ packages = packages,
+ )
+
+ # Send an empty response
+ self.set_status(204)
+ self.finish()
# Try to dispatch the next job
await self.backend.jobs.queue.dispatch()
if builds:
self.backend.run_task(self.backend.builds.launch, builds)
- # Send something back to the builder
- self.finish({})
-
class APIv1LogStreamHandler(base.BackendMixin, tornado.websocket.WebSocketHandler):
# No authentication required