Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _init_haros_dir(self, overwrite=False):
print "[HAROS] Running setup operations..."
exists = os.path.exists(self.haros_dir)
if exists and not os.path.isdir(self.haros_dir):
raise RuntimeError(("Could not initialise; " + self.haros_dir
+ " already exists and is not a directory."))
if not exists:
self.log.info("Creating %s", self.haros_dir)
os.makedirs(self.haros_dir)
self._generate_dir(self.haros_dir, self.DIR_STRUCTURE,
overwrite=overwrite)
if overwrite or not os.path.exists(self.viz_dir):
viz.install(self.viz_dir, self.run_from_source, force=True, minimal_output=self.minimal_output)
return True
def _save_results(self, node_cache):
print "[HAROS] Saving analysis results..."
if self.export_viz:
viz.install(self.viz_dir, self.run_from_source, minimal_output=self.minimal_output)
self._ensure_dir(self.data_dir)
self._ensure_dir(self.current_dir)
# NOTE: The database has a tendency to grow in size.
# Old reports will have violations and metrics with references
# to old packages, files, etc. There will be multiple versions
# of the same projects over time, as long as the history exists.
# This is why I added "_compact()" to the database's save_state()
# function.
if not self.minimal_output:
self.database.save_state(os.path.join(self.current_dir, "haros.db"))
self.log.debug("Exporting on-memory data manager.")
self._prepare_project()
exporter = JsonExporter()
self._export_project_data(exporter)
exporter.export_projects(self.data_dir, (self.database.project,),
overwrite = False)
def _prepare_directory(self):
if self.export_viz:
viz.install(self.viz_dir, self.run_from_source)
self._ensure_dir(self.data_dir)
self._ensure_dir(self.io_projects_dir)