Biskit ::
ExeConfig ::
ExeConfig ::
Class ExeConfig
|
|
Class ExeConfig
source code
ExeConfig
Manage the settings that Executor needs for calling an external
program.
ExeConfig is initialised with a program name and expects to find the
configuration for this program in ~/.biskit/exe_|name|.dat
. Only if nothing is found there, it looks for
external/defaults/exe_|name|.dat
in the biskit installation
folder. If neither of the two files are found, an error is raised
(strict=1) or the binary is assumed to be |name| and must be accessible
in the search path (strict=0).
Example
The configuration file (exe_name.dat) should look like this:
---- start example configuration file ----
[BINARY]
comment=the emacs editor
bin=emacs
cwd=
shell=0
shellexe=
pipes=0
## Use new environment containing only variables given below
replaceEnv=0
[ENVIRONMENT]
HOME=
EMACS_CONFIG=~/.emacs/config.dat
---- end of example file ----
This example config would ask Executor to look for an executable
called 'emacs' in the local search path. Before running it, executor
should check that a variable $HOME exists in the local shell
environment (or raise an error otherwise) and set the variable
$EMACS_CONFIG to the given path.
The other settings specify how the program call is done (see also
Python 2.4 subprocess.Popen() ):
-
cwd ... working directory (empty -- current working
directory)
-
shell ... wrap process in separate shell
-
shellexe ... which shell (empty -- sh)
-
pipes ... paste input via STDIN, collect output at
STDOUT
Missing options are reset to their default value; See
ExeConfig.reset() . All entries in section BINARY are put into
the name space of the ExeConfig object. That means an ExeConfig
object x created from the above file can be used as follows:
>>> x = ExeConfig( 'emacs' )
>>> x.cwd == None
>>> True
>>> print x.comment
>>> the emacs editor
|
__init__(self,
name,
strict=1)
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
|
|
reset(self)
Reset all required parameters.
|
|
update(self)
Load settings from associated configuration file (if
available).
|
|
validate(self)
Validate the path to the binary.
|
{str:str} OR None
|
environment(self)
Get needed environment variables.
|
[str]
|
update_environment(self)
Check for missing environment settings.
|
|
__repr__(self)
repr(x)
|
|
__str__(self)
str(x)
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__
|
|
name
identifier
|
|
dat
path to configuration file
|
|
dat_found
True if a configuration file was found
|
Inherited from object :
__class__
|
__init__(self,
name,
strict=1)
(Constructor)
| source code |
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
-
- Parameters:
name (str ) - unique name of the program
strict (0|1 ) - insist on a config file exe_name.dat and do not tolerate
missing environment variables (default: 1)
- Raises:
- Overrides:
object.__init__
|
Reset all required parameters. Called at creation
-
|
Load settings from associated configuration file (if available). Is
automatically called at creation.
-
- Raises:
|
Validate the path to the binary.
-
- Raises:
|
Get needed environment variables.
-
- Returns:
{str:str} OR None
- dictionary with environment for subprocess.Popen OR None, if
no environment was specified
- Raises:
|
Check for missing environment settings.
-
- Returns:
[str]
- names of required but missing environment variables
|
repr(x)
-
- Overrides:
object.__repr__
- (inherited documentation)
|
__str__(self)
(Informal representation operator)
| source code |
str(x)
-
- Overrides:
object.__str__
- (inherited documentation)
|
PATH_CONF_DEFAULT
-
- Value:
os.path.join(T.projectRoot(), 'external/defaults')
|
|
dat
path to configuration file
-
|
dat_found
True if a configuration file was found
-
|