Biskit :: ExeConfig :: ExeConfig :: Class ExeConfig
[hide private]
[frames] | no frames]

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() ): 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


Instance Methods [hide private]
  __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__


Class Variables [hide private]
  PATH_CONF = user.home+ '/.biskit'
  PATH_CONF_DEFAULT = os.path.join(T.projectRoot(), 'external/defaults')
  SECTION_BIN = 'BINARY'
  SECTION_ENV = 'ENVIRONMENT'

Instance Variables [hide private]
  name
identifier
  dat
path to configuration file
  dat_found
True if a configuration file was found

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__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(self)

source code 

Reset all required parameters. Called at creation

update(self)

source code 

Load settings from associated configuration file (if available). Is automatically called at creation.
Raises:

validate(self)

source code 

Validate the path to the binary.
Raises:

environment(self)

source code 

Get needed environment variables.
Returns: {str:str} OR None
dictionary with environment for subprocess.Popen OR None, if no environment was specified
Raises:

update_environment(self)

source code 

Check for missing environment settings.
Returns: [str]
names of required but missing environment variables

__repr__(self)
(Representation operator)

source code 

repr(x)
Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)
Overrides: object.__str__
(inherited documentation)

Class Variable Details [hide private]

PATH_CONF

Value:
user.home+ '/.biskit'                                                  
      

PATH_CONF_DEFAULT

Value:
os.path.join(T.projectRoot(), 'external/defaults')                     
      

SECTION_BIN

Value:
'BINARY'                                                               
      

SECTION_ENV

Value:
'ENVIRONMENT'                                                          
      

Instance Variable Details [hide private]

name


identifier

dat


path to configuration file

dat_found


True if a configuration file was found