def close_job(self, job): """ Close a job after pushing reports / binaries up. """ j = Job.load(job) j['finished_at'] = dt.datetime.utcnow() return j.save()
def submit_report(self, report, job, failed): """ Submit a report from a run. report - firehose lint job job - job ID this relates to failed - was it able to complete properly """ job = Job.load(job) package = job.get_package() report = Report(report=report, builder=get_builder_id(), package=package['_id'], package_type=job['package_type'], job=job['_id'], failed=failed) uuid_path = uuid_to_path(job['_id']) path = os.path.join(config['pool'], uuid_path) if not os.path.exists(path): os.makedirs(path) report['log_path'] = os.path.join(uuid_path, 'log') report['firehose_path'] = os.path.join(uuid_path, 'firehose.xml') rid = report.save() if failed: send_failed_email(job, package, report) return rid
def forfeit_job(self, job): j = Job.load(job) buildd = j.get_builder() if buildd['_id'] != get_builder_id(): return None # meh j['assigned_at'] = None j['builder'] = None return j.save()
def accept_binary(config, changes): key = changes.validate_signature() arch = changes['Architecture'] if " " in arch: arches = set(arch.split(" ")) if "all" in arches: arches.remove("all") arches = list(arches) if len(arches) != 1: return reject(config, changes, 'too-many-arches') arch = changes._data['Architecture'] = arches[0] suite = changes['Distribution'] binaries = changes.get_files() try: job = changes['x-lucy-job'] except KeyError: return reject(config, changes, 'no-job') try: job = Job.load(job) except KeyError: return reject(config, changes, 'invalid-job') try: buildd = Machine.get_by_key(key) except KeyError: return reject(config, changes, 'youre-not-a-machine') binary = Binary(job=job['_id'], arch=arch, suite=suite, binaries=[os.path.basename(x) for x in binaries], builder=buildd['_id']) binary.save() add_jobs(binary, 'binary', config, 'binary', changes) path = move_to_pool(config, binary['source'], changes, root=arch) os.unlink(changes.get_filename()) print("accept binary")