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 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 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