def process(self): try: p = get_project(self.job.inputs["project_id"]) vs = ViewSet(p.db, p.get_viewset_id()) create_thumbnails_from_ucsc(self.job.inputs["session_url"], vs, pixels=self.job.inputs["image_width"], margins=self.job.inputs.get( "margins", 0), job=self.job) p.set_data("has_images", True) #send email url = p.get_url(external=True) user = db.session.query(User).filter_by(id=self.job.user_id).one() send_email(user, "Images Created", "ucsc_image_job_finished", url=url) p.set_data("creating_images_job_status", "complete") self.complete() except Exception as e: app.logger.exception("Error in ucsc upload # {}".format( self.job.id)) p.set_data("creating_images_job_status", "failed") self.failed(traceback.format_exc())
def create_from_avocato_output(self, output_dir=""): self.set_data("remote_avacato_dir", output_dir) remote_file = os.path.join(output_dir, "cell", "cell_all.csv") tf = get_temporary_folder() local_file = os.path.join(tf, "cell.csv") remote_file = shlex.quote(remote_file) os.system("wget {} -O {}".format(remote_file, local_file)) line_num = 0 headers = [] #work put headers with open(local_file) as f: for line in f: arr = line.strip().split(",") if line_num == 0: for c, item in enumerate(arr, start=1): headers.append({"name": item, "position": c}) line_num += 1 continue if line_num == 1: for c, item in enumerate(arr): type = "text" try: int(item) type = "integer" except: try: float(item) type = "double" except: pass headers[c]["datatype"] = type break self.add_data_file(has_headers=True, files={"upload_file": local_file}, fields=headers, delimiter=",") user = db.session.query(User).filter_by(id=self.owner).one() send_email(user, "Job Finished", "job_finished", url=self.get_url(external=True), type="Avacato Visualisation")
def process(self): try: p = get_project(self.job.inputs["project_id"]) vs = ViewSet(p.db, p.get_viewset_id()) create_thumbnails_from_mlv( self.job.inputs["tracks"], vs, image_width=self.job.inputs["image_width"], margins=self.job.inputs.get("margins", 0), job=self.job) p.refresh_data() p.set_data("has_images", True) hid = self.get_input_parameter("history_id") history = p.get_history(hid) history["tracks"] = [] history["fields"] = [] history["graphs"] = [] history["status"] = "complete" p.update() #send email url = p.get_url(external=True) user = db.session.query(User).filter_by(id=self.job.user_id).one() send_email(user, "Images Created", "ucsc_image_job_finished", url=url) self.complete() except Exception as e: p = get_project(self.job.inputs["project_id"]) hid = self.get_input_parameter("history_id") history = p.get_history(hid) history["status"] = "failed" p.update() app.logger.exception("Error in creating mlv images # {}".format( self.job.id)) self.failed(traceback.format_exc())
def process(self, pword): try: p = get_project(self.job.inputs["project_id"]) p.set_data("zegami_upload_job", { "job_id": self.job.id, "job_status": "running" }) vs = ViewSet(p.db, p.get_viewset_id()) credentials = { "project": self.job.inputs["project"], "username": self.job.inputs["username"], "password": pword } url = vs.create_zegami_collection(name=p.name, job=self.job, credentials=credentials) p.set_data("zegami_url", url) vs.upload_images_to_zegami(job=self.job, credentials=credentials) #send email user = db.session.query(User).filter_by(id=self.job.user_id).one() send_email(user, "Zegami Collection Created", "zegami_collection_created", url=url) self.complete() except Exception as e: app.logger.exception("Error in zegami upload # {}".format( self.job.id)) p.set_data("zegami_upload_job", { "job_id": self.job.id, "job_status": "failed" }) self.failed(traceback.format_exc())
def test_email(): from app.jobs.email import send_email from app.databases.user_models import User user = db.session.query(User).filter_by(id=2).one() send_email(user, "test", "test_email", info="hello")