def execute(self): workspace_path = os.path.join(self.results_path, self.args.workspace) projects_path = os.path.join(workspace_path, "projects") qc_path = os.path.join(workspace_path, "quality_control") self.log.info("Preparing output path at {} ...".format(os.path.relpath(qc_path, self.runtime_path))) self.create_output_path(qc_path) loader = ChoiceLoader([ PackageLoader(__name__, 'qc_templates'), FileSystemLoader(os.path.join(self.root_path, "web", "templates")) ]) env = Environment(loader=loader, autoescape=False) env.globals.update( version=VERSION, creation_date=str(datetime.now()) ) env.filters["tojson"] = tojson self.log.info("Looking for projects ...") projects = [] quality_controls = [] for project_path in sorted(os.listdir(projects_path)): project_path = os.path.join(projects_path, project_path) proj_res = ProjectResults(path=project_path) project = proj_res.load_def() quality = proj_res.load_quality_control() projects += [project] quality_controls += [quality] self.log.info("Processing {} projects ...".format(len(projects))) for i, project in enumerate(projects): self.log.info("Processing report for project {} ...".format(project["id"])) quality = quality_controls[i] t = env.get_template("project.html") context=dict( index=i, project=project, quality=quality, projects=projects) t.stream(context).dump(os.path.join(qc_path, "project_{}.html".format(project["id"]))) self.log.info("Generating index.html ...") t = env.get_template("index.html") t.stream(projects=projects).dump(os.path.join(qc_path, "index.html"))
def __load_case_info(case, except_enabled=False, quality_enabled=False): wok = current_app.wok case_info = dict( id=case.id, name=case.name, created=case.created, removed=case.removed) if case.properties is not None: case_path = case.properties["path"] quality = None if quality_enabled: project_results = ProjectResults(path=case_path) quality = project_results.load_quality_control() zip_path = os.path.join(case_path, "results.zip") website_path = os.path.join(case_path, "website", "results", "project.tsv") case_info.update( analysis_type=case.properties["analysis_type"], results_available=os.path.exists(zip_path), website_available=os.path.exists(website_path), quality=quality if quality is not None and len(quality) > 0 else None) engine_case = wok.engine.case(case.engine_name) if engine_case is not None: exceptions = None if except_enabled: exceptions = __engine_case_exceptions(engine_case) case_info.update( state=engine_case.state.title, started=engine_case.started, finished=engine_case.finished, elapsed=engine_case.elapsed, progress=__engine_case_progress(engine_case), exceptions=exceptions) return case_info