def end_build_job(playlist, job, success): """ Register in database that a build is finished. Emits an event to notify clients that the build is done. """ if success: status = "succeeded" else: status = "failed" build_job = BuildJob.get(job["id"]) if build_job is not None: build_job.end(status=status) events.emit( "build-job:update", { "build_job_id": job["id"], "playlist_id": playlist["id"], "status": status, }, project_id=playlist["project_id"], ) if build_job is not None: return build_job.serialize() else: return {}
def generate_fixture_build_job(self, ended_at, playlist_id=None): if playlist_id is None: playlist_id = self.playlist.id self.build_job = BuildJob.create(status="succeeded", job_type="movie", ended_at=ended_at, playlist_id=playlist_id) return self.build_job.serialize()
def end_build_job(playlist, job): """ Register in database that a build is finished. Emits an event to notify clients that the build is done. """ build_job = BuildJob.get(job["id"]) build_job.end() events.emit("build-job:success", { "build_job_id": str(build_job.id), "playlist_id": playlist["id"] }) return build_job.serialize()
def start_build_job(playlist): """ clients that a new job is running. Register in database that a new build is running. Emits an event to notify """ job = BuildJob.create(status="running", job_type="movie", playlist_id=playlist["id"]) events.emit("build-job:new", { "build_job_id": str(job.id), "playlist_id": playlist["id"], "created_at": fields.serialize_value(job.created_at), }, project_id=playlist["project_id"]) return job.serialize()
def remove_build_job(playlist, build_job_id): """ Remove build job from database and remove related temporary file from hard drive. """ job = BuildJob.get(build_job_id) movie_file_path = get_playlist_movie_file_path(playlist, job.serialize()) if os.path.exists(movie_file_path): os.remove(movie_file_path) file_store.remove_movie("playlists", build_job_id) job.delete() events.emit("build-job:delete", { "build_job_id": build_job_id, "playlist_id": playlist["id"] }) return movie_file_path
def end_build_job(playlist, job, result): """ Register in database that a build is finished. Emits an event to notify clients that the build is done. """ build_job = BuildJob.get(job["id"]) build_job.end() status = "succeeded" if not result["success"]: status = "failed" events.emit("build-job:update", { "build_job_id": str(build_job.id), "playlist_id": playlist["id"], "status": status, }, project_id=playlist["project_id"]) return build_job.serialize()
def remove_build_job(playlist, build_job_id): """ Remove build job from database and remove related temporary file from hard drive. """ job = BuildJob.get(build_job_id) movie_file_path = get_playlist_movie_file_path(playlist, job.serialize()) if os.path.exists(movie_file_path): os.remove(movie_file_path) try: file_store.remove_movie("playlists", build_job_id) except: current_app.logger.error("Playlist file can't be deleted: %s" % build_job_id) job.delete() events.emit("build-job:delete", { "build_job_id": build_job_id, "playlist_id": playlist["id"] }, project_id=playlist["project_id"]) return movie_file_path