"""
Called from the async IO loop doing all the work
"""
+ success = False
+
# Extract the job id
job_id = self.data.get("id")
if not job_id:
# Setup build logger
logger = BuildLogger(self.log, self.job)
- # Send a new status
- await self.job.status("building")
-
# Run the build
try:
build = self._build(pkg, arch=arch,
while not build.done():
await logger.stream(timeout=1)
+ # Catch any other Exception
+ except Exception as e:
+ raise e
+
+ # The build has finished successfully
+ else:
+ success = True
+
+ # Notify the hub that the job has finished
finally:
- # Upload the build log
- log_upload_id = await self.hub.upload(
- logger.logfile.name,
- filename="%s.log" % job_id,
+ await self.hub.finish_job(
+ job_id,
+ success=success,
+ log=logger.logfile.name,
)
def _build(self, pkg, arch=None, logger=None, **kwargs):
# Return a Job proxy
return Job(self, id, conn)
+ async def finish_job(self, job_id, success, log):
+ """
+ Will tell the hub that a job has finished
+ """
+ # Upload the log file
+ if log:
+ log = await self.upload(log, filename="%s.log" % job_id)
+
+ # Send the request
+ response = await self._request("POST", "/jobs/%s/finished" % job_id,
+ success=success, log=log)
+
+ # Handle the response
+ # XXX TODO
+
class Job(object):
"""