paks package
Submodules
paks.client module
paks.defaults module
paks.schemas module
paks.settings module
-
class
paks.settings.
Settings
(settings_file, validate=True)[source] Bases:
paks.settings.EmptySettings
The settings class is a wrapper for easily parsing a settings.yml file.
We parse into a query-able class. It also gives us control to update settings, meaning we change the values and then write them to file. It’s basically a dictionary-like class with extra functions.
paks.version module
paks.logger module
-
class
paks.logger.
ColorizingStreamHandler
(nocolor=False, stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, use_threads=False)[source] Bases:
logging.StreamHandler
-
BLACK
= 0
-
BLUE
= 4
-
BOLD_SEQ
= '\x1b[1m'
-
COLOR_SEQ
= '\x1b[%dm'
-
CYAN
= 6
-
GREEN
= 2
-
MAGENTA
= 5
-
RED
= 1
-
RESET_SEQ
= '\x1b[0m'
-
WHITE
= 7
-
YELLOW
= 3
-
colors
= {'CRITICAL': 1, 'DEBUG': 4, 'ERROR': 1, 'INFO': 2, 'WARNING': 3}
-
emit
(record)[source] Emit a record.
If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.
-
property
is_tty
-
paks.backends.base module
-
class
paks.backends.base.
ContainerName
(raw)[source] Bases:
object
Parse a container name into named parts
-
property
extended_name
-
property
name
-
property
slug
-
property
-
class
paks.backends.base.
ContainerTechnology
(settings=None)[source] Bases:
object
A base class for a container technology
-
get_history
(line, openpty)[source] Given an input with some number of up/down and newline, derive command.
-
paks.backends.docker module
-
class
paks.backends.docker.
DockerContainer
(image, settings=None)[source] Bases:
paks.backends.base.ContainerTechnology
A Docker container controller.
-
command
= 'docker'
-
paks.backends.podman module
paks.commands module
paks.commands.command module
-
class
paks.commands.command.
Command
(tech, required=None, out=None)[source] Bases:
object
Class method to invoke shell commands and retrieve output and error. This class is inspired and derived from utils functions in https://github.com/vsoch/scif
-
check
(**kwargs)[source] Check ensures that:
- The container tech of the command matches the class
- Required arguments are provided.
-
decode
(line)[source] Given a line of output (error or regular) decode using the system default, if appropriate
-
execute_get
(runcmd, getcmd)[source] Execute and get runs a command inside the container (pipes to temporary file) and then loads from the outside.
-
parse_command
(cmd)[source] this is called when a new command is provided to ensure we have a list. We don’t check that the executable is on the path, as the initialization might not occur in the runtime environment.
-
parse_kwargs
= True
-
pre_message
= None
-
run_command
(cmd, output='output')[source] Wrapper to stream a command, which handles returning a result on error.
Run a hidden command.
-
supported_tech
= ['docker', 'podman', 'singularity']
-
paks.commands.state module
-
class
paks.commands.state.
SaveContainer
(tech, required=None, out=None)[source] Bases:
paks.commands.command.Command
-
pre_message
= 'Saving container...'
-
run
(**kwargs)[source] Save a temporary container name back to the main container name Available after check - validated self.kwargs
-
supported_for
= ['docker', 'podman']
-
paks.utils module
paks.utils.fileio module
-
paks.utils.fileio.
copyfile
(source, destination, force=True)[source] Copy a file from a source to its destination.
-
paks.utils.fileio.
get_file_hash
(image_path, algorithm='sha256')[source] Return an sha256 hash of the file based on a criteria level.
-
paks.utils.fileio.
get_tmpdir
(tmpdir=None, prefix='', create=True)[source] Get a temporary directory for an operation.
-
paks.utils.fileio.
get_tmpfile
(tmpdir=None, prefix='')[source] Get a temporary file with an optional prefix.
-
paks.utils.fileio.
mkdir_p
(path)[source] mkdir_p attempts to get the same functionality as mkdir -p :param path: the path to create.
-
paks.utils.fileio.
recursive_find
(base, pattern=None)[source] Find filenames that match a particular pattern, and yield them.
paks.utils.names module
paks.utils.terminal module
-
paks.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)) –
-
paks.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) –
-
paks.utils.terminal.
get_installdir
()[source] get_installdir returns the installation directory of the application
-
paks.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) –