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, tee=False, encoding='utf-8')[source]¶ Run a subprocess, wait for it to complete and return a
ProcessResults
object. This function differs fromstart_process()
in the type it returns and the fact that it always waits for the subprocess to finish before returning.Changed in version 1.15.0: Added the tee parameter.
Parameters: Returns: The results of the process including the status code and any text printed to stdout or stderr.
Return type:
-
start_process
(process_args, wait=True, cwd=None)[source]¶ Start a subprocess and optionally wait for it to finish. If not wait, a handle to the subprocess is returned instead of
True
when it exits successfully. This function differs fromrun_process()
in that it optionally waits for the subprocess to finish, and can return a handle to it.Parameters: Returns: If wait is set to True, then a boolean indication success is returned, else a handle to the subprocess is returened.
-
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