1.20. startup
¶
This module provides generic functions for the early initialization of the project’s environment. This is primarily used for the management of external dependencies.
Note
This is a “Clean Room” module and is suitable for use during initialization.
1.20.1. Functions¶
-
argp_add_client
(parser)[source]¶ Add client-specific arguments to a new
argparse.ArgumentParser
instance.Parameters: parser ( argparse.ArgumentParser
) – The parser to add arguments to.
-
argp_add_default_args
(parser, default_root='')[source]¶ Add standard arguments to a new
argparse.ArgumentParser
instance. Used to add the utilities argparse options to the wrapper for display.Parameters: - parser (
argparse.ArgumentParser
) – The parser to add arguments to. - default_root (str) – The default root logger to specify.
- parser (
-
argp_add_server
(parser)[source]¶ Add server-specific arguments to a new
argparse.ArgumentParser
instance.Parameters: parser ( argparse.ArgumentParser
) – The parser to add arguments to.
-
pipenv_entry
(parser, entry_point)[source]¶ Run through startup logic for a Pipenv script (see Pipenv: Custom Script Shortcuts for more information). This sets up a basic stream logging configuration, establishes the Pipenv environment and finally calls the actual entry point using
os.execve()
.Note
Due to the use of
os.execve()
, this function does not return.Note
Due to the use of
os.execve()
andos.EX_*
exit codes, this function is not available on Windows.Parameters: - parser – The argument parser to use. Arguments are added to it and extracted before passing the remainder to the entry point.
- entry_point (str) – The name of the entry point using Pipenv.
-
run_process
(process_args, cwd=None, encoding='utf-8')[source]¶ Start a process, wait for it to complete and return a
ProcessResults
object.Parameters: - process_args – The arguments for the processes including the binary.
- cwd – An optional current working directory to use for the process.
- encoding (str) – The encoding to use for strings.
Returns: The results of the process including the status code and any text printed to stdout or stderr.
Return type:
-
which
(program)[source]¶ Examine the
PATH
environment variable to determine the location for the specified program. If it can not be found None is returned. This is fundamentally similar to the Unix utility of the same name.Parameters: program (str) – The name of the program to search for. Returns: The absolute path to the program if found. Return type: str