spliced.utils package

Submodules

spliced.utils.fileio module

spliced.utils.fileio.copyfile(source, destination, force=True)[source]

Copy a file from a source to its destination.

spliced.utils.fileio.get_file_hash(image_path, algorithm='sha256')[source]

Return an sha256 hash of the file based on a criteria level.

spliced.utils.fileio.get_tmpdir(tmpdir=None, prefix='', create=True)[source]

Get a temporary directory for an operation.

spliced.utils.fileio.get_tmpfile(tmpdir=None, prefix='')[source]

Get a temporary file with an optional prefix.

spliced.utils.fileio.mkdir_p(path)[source]

mkdir_p attempts to get the same functionality as mkdir -p :param path: the path to create.

spliced.utils.fileio.mkdirp(dirnames)[source]

Create one or more directories

spliced.utils.fileio.print_json(json_obj)[source]

Print json pretty

spliced.utils.fileio.read_file(filename, mode='r')[source]

Read a file.

spliced.utils.fileio.read_json(filename)[source]
spliced.utils.fileio.read_yaml(filename)[source]
spliced.utils.fileio.recursive_find(base, pattern=None)[source]

Find filenames that match a particular pattern, and yield them.

spliced.utils.fileio.write_file(filename, content, mode='w')[source]

Write content to a filename

spliced.utils.fileio.write_json(content, filename)[source]

spliced.utils.terminal module

spliced.utils.terminal.add_spack_to_path()[source]

Find spack and add to path, allowing for import of spack modules

spliced.utils.terminal.check_install(software, quiet=True, command='--version')[source]

check_install will attempt to run the singularity command, and return True if installed. The command line utils will not run without this check.

Parameters:
  • software (the software to check if installed) –

  • quiet (should we be quiet? (default True)) –

  • command (the command to use to check (defaults to --version)) –

spliced.utils.terminal.confirm_action(question, force=False)[source]

confirm if the user wants to perform a certain action

Parameters:
  • question (the question that will be asked) –

  • force (if the user wants to skip the prompt) –

spliced.utils.terminal.confirm_uninstall(filename, force=False)[source]

confirm if the user wants to uninstall a module

Parameters:
  • filename (the file that will be removed) –

  • force (if the user wants to skip the prompt) –

spliced.utils.terminal.get_installdir()[source]

get_installdir returns the installation directory of the application

spliced.utils.terminal.run_command(cmd, stream=False)[source]

run_command uses subprocess to send a command to the terminal.

Parameters:
  • cmd (the command to send, should be a list for subprocess) –

  • error_message (the error message to give to user if fails,) –

  • failed. (if none specified, will alert that command) –

spliced.utils.terminal.which(software, strip_newline=True)[source]

get_install will return the path to where Singularity (or another executable) is installed.

Module contents