def create_or_update_job(self, job_id, image, command): from fastlane.models.job import Job jobs = list(filter(lambda job: str(job.job_id) == job_id, self.jobs)) if not jobs: j = Job(task_id=str(self.task_id), job_id=str(job_id)) j.task = self j.image = image j.command = command j.save() self.jobs.append(j) self.save() else: j = jobs[0] j.image = image j.command = command j.save() return j
def create_job(self, image, command): from fastlane.models.job import Job job_id = uuid4() j = Job(task_id=str(self.task_id), job_id=str(job_id)) j.task = self j.image = image j.command = command j.save() self.jobs.append(j) self.save() return j