Interfacing with other software environments (pwkit.environments)

pwkit.environments - working with external software environments

Classes:

Environment - base class for launching programs in an external environment.

Submodules:

heasoft - HEAsoft sas - SAS

Functions:

prepend_environ_path - Prepend into a $PATH in an environment dict. prepend_path - Prepend text into a $PATH-like environment variable. user_data_path - Generate paths for storing miscellaneous user data.

Standard usage is to create an Environment instance, then use its launch(argv, …) method to run programs in the specified environment. launch() returns a subprocess.Popen instance that can be used in the standard ways.

pwkit.environments.prepend_environ_path(env, name, text, pathsep=':')[source]

Prepend text into a $PATH-like environment variable. env is a dictionary of environment variables and name is the variable name. pathsep is the character separating path elements, defaulting to os.pathsep. The variable will be created if it is not already in env. Returns env.

Example:

prepend_environ_path(env, 'PATH', '/mypackage/bin')

The name and text arguments should be str objects; that is, bytes in Python 2 and Unicode in Python 3. Literal strings will be OK unless you use the from __future__ import unicode_literals feature.

pwkit.environments.prepend_path(orig, text, pathsep=':')[source]

Returns a $PATH-like environment variable with text prepended. orig is the original variable value, or None. pathsep is the character separating path elements, defaulting to os.pathsep.

Example:

newpath = cli.prepend_path(oldpath, ‘/mypackage/bin’)

See also prepend_environ_path.