hbp_nrp_commons.workspace.sim_util module

This module implements Utility functions used by backend

class hbp_nrp_commons.workspace.sim_util.SimUtil[source]

Bases: object

Utility methods for a simulation

static clear_dir(directory: str) → None[source]

Deletes contents of a directory

static delete_simulation_dir(sim_dir=None)[source]

Removes simulation directory.

Checks that you are deleting the right folder by checking the sim_id.

static extract_sim_id(sim_dir: str) → Optional[int][source]
Parameters

sim_dir – the address of temp folder

Returns

returns the sim_id embedded in sim_dir.

static find_file_in_paths(file_rel_path: str, path_list: List[str]) → Optional[str][source]
Returns

returns the absolute path of the first file found in path_list. if not found, returns and empty string.

static init_simulation_dir(sim_id: str) → str[source]

Creates a temporary directory and links it to Settings.sim_dir_symlink

Params sim_id

simulation ID of the simulation we’re going to create a temp dir for we embed the sim_id into simulation temp dir so the delete_simulation_dir deletes correctly

Returns sim_dir

the full path of the address of temp dir for the simulation

static makedirs(directory: str) → None[source]

Creates [nested] directory if not exists

Raises

all errors except directory exists

static mkdir(directory: str) → None[source]

Creates [nested] directory if not exists

Raises

all errors except directory exists

static rmdir(directory: str) → None[source]

Removes [nested] directory if not exists

Raises

all errors except directory exists