glxshell.lib.environ module
-
exception glxshell.lib.environ.EINVAL[source]
Bases: Exception
-
exception glxshell.lib.environ.ENOMEM[source]
Bases: Exception
-
class glxshell.lib.environ.GLXEnviron[source]
Bases: object
-
property environ: dict
Return the environ property value
-
getenv(name=None)[source]
getenv - get value of an environment variable
The getenv() function shall search the environment of the calling process for
the environment variable name if it exists and return the value of the environment variable. If
the specified environment variable cannot be found, None shall be returned.
- Parameters:
name (str) – the key name
-
setenv(envname=None, envval=None, overwrite=None)[source]
setenv - add or change environment variable
The setenv() function shall update or add a variable in the environment of the calling process. The envname
argument points to a string containing the name of an environment variable to be added or altered. The
environment variable shall be set to the value to which envval points. The function shall fail if envname
points to a string which contains an ‘=’ character. If the environment variable named by envname already
exists and the value of overwrite is non-zero, the function shall return success and the environment shall be
updated. If the environment variable named by envname already exists and the value of overwrite is zero,
the function shall return success and the environment shall remain unchanged.
- Parameters:
envname (str) – the key name
envval (str) – the value of the key
overwrite (int) – non-zero
- Raises:
EINVAL – when envname argument points to an empty string or points to a string containing an ‘=’ character
ENOMEM – when Insufficient memory was available to add a variable or its value to the environment.
TypeError – when he name argument value is not a str type or None
- Returns:
0 if success, otherwise -1
- Return type:
int
-
unsetenv(name)[source]
unsetenv - remove an environment variable
The unsetenv() function shall remove an environment variable from the environment of the calling process. The
name argument points to a string, which is the name of the variable to be removed. The named argument shall
not contain an ‘=’ character. If the named variable does not exist in the current environment,
the environment shall be unchanged and the function is considered to have completed successfully.
- Parameters:
name (str) – the name of the variable to be removed
- Raises:
EINVAL – when he name argument value is an empty string, or a string containing an ‘=’ character.
TypeError – when he name argument value is not a str type or None
- Returns:
0 if success, otherwise -1
- Return type:
int
|