def _make_odir(self): """Create the output directory.""" # If renew_odir flag is True - then move it. if self.renew_odir: clean_odirs(odir=self.deploy.odir, max_odirs=self.max_odirs) os.makedirs(self.deploy.odir, exist_ok=True)
def prepare_workspace_for_cfg(cfg): '''Overrides Launcher.prepare_workspace_for_cfg.''' # Create the job dir. LsfLauncher.jobs_dir[cfg] = Path(cfg.scratch_path, "lsf", cfg.timestamp) clean_odirs(odir=LsfLauncher.jobs_dir[cfg], max_odirs=2) os.makedirs(Path(LsfLauncher.jobs_dir[cfg]), exist_ok=True)
def __init__(self, run_items, sim_cfg): # Construct the cov_db_dirs right away from the run_items. This is a # special variable used in the HJson. self.cov_db_dirs = [] for run in run_items: if run.cov_db_dir not in self.cov_db_dirs: self.cov_db_dirs.append(run.cov_db_dir) # Early lookup the cov_merge_db_dir, which is a mandatory misc # attribute anyway. We need it to compute additional cov db dirs. self.cov_merge_db_dir = subst_wildcards("{cov_merge_db_dir}", sim_cfg.__dict__) # Prune previous merged cov directories, keeping past 7 dbs. prev_cov_db_dirs = clean_odirs(odir=self.cov_merge_db_dir, max_odirs=7) # If the --cov-merge-previous command line switch is passed, then # merge coverage with the previous runs. if sim_cfg.cov_merge_previous: self.cov_db_dirs += [str(item) for item in prev_cov_db_dirs] super().__init__(sim_cfg) self.dependencies += run_items # Run coverage merge even if one test passes. self.needs_all_dependencies_passing = False # Append cov_db_dirs to the list of exports. self.exports["cov_db_dirs"] = "\"{}\"".format(" ".join( self.cov_db_dirs))
def write_results_html(self): # Prepare workspace to generate reports. # Keep up to 2 weeks results. clean_odirs(odir=self.results_path, max_odirs=14) mk_path(self.results_path) # Write results to the report area. if self.is_primary_cfg: results_html = md_results_to_html(self.results_title, self.css_file, self.results_summary_md) result_path = os.path.join(self.results_path, "summary.html") else: results_html = md_results_to_html(self.results_title, self.css_file, self.results_md) result_path = os.path.join(self.results_path, "results.html") with open(result_path, "w") as results_file: results_file.write(results_html) log.log(VERBOSE, "[results page]: [%s][%s], self.name, results_path")
def write_results_html(self, filename, text_md): '''Convert given text_md to html format and write it to file with given filename. ''' # Prepare workspace to generate reports. # Keep up to 2 weeks results. # If path exists, skip clean_odirs and directly update the files in the existing path. if not (os.path.exists(self.results_path)): clean_odirs(odir=self.results_path, max_odirs=14) mk_path(self.results_path) mk_path(self.symlink_path) # Prepare results and paths. text_html = md_results_to_html(self.results_title, self.css_file, text_md) result_path = os.path.join(self.results_path, filename) symlink_path = os.path.join(self.symlink_path, filename) # Write results to the report area. with open(result_path, "w") as results_file: results_file.write(text_html) log.log(VERBOSE, "[results page]: [%s][%s], self.name, results_path") # Link the `/latest` folder with the latest reports. mk_symlink(result_path, symlink_path)