| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# ProcessJobOptions Namespace Reference

## Classes
class | LogFormatter
class | LogFilter
class | ConsoleHandler
class | ParserError
class | JobOptsParser
class | _TempSysPath
## Functions
def | GetConsoleHandler
def | InstallRootLoggingHandler
def | PrintOn
def | PrintOff
def | _find_file
def | _to_be_included
def | _import_python
def | _import_pickle
def | _import_opts
def | importOptions
def | importUnits
| Import a file containing declaration of units.
## Variables
tuple | _log = logging.getLogger(__name__)
| _consoleHandler = None
tuple | _included_files = set()
tuple | _parser = JobOptsParser()
dictionary | _import_function_mapping

## Function Documentation

def ProcessJobOptions::_find_file | ( |  | f | ) | `[private]`

Definition at line 107 of file ProcessJobOptions.py.

    00107                  :
    00108     # expand environment variables in the filename
    00109     f = os.path.expandvars(f)
    00110     if os.path.isfile(f):
    00111         return os.path.realpath(f)
    00112
    00113     path = os.environ.get('JOBOPTSEARCHPATH','').split(os.pathsep)
    00114     # find the full path to the option file
    00115     candidates = [d for d in path if os.path.isfile(os.path.join(d,f))]
    00116     if not candidates:
    00117         raise ParserError("Cannot find '%s' in %s" % (f,path))
    00118     return os.path.realpath(os.path.join(candidates[0],f))
    00119
    _included_files = set()

def ProcessJobOptions::_import_opts | ( |  | file | ) | `[private]`

Definition at line 386 of file ProcessJobOptions.py.

    00386                       :
    00387     _parser.parse(file)
    00388
    _import_function_mapping = {

def ProcessJobOptions::_import_pickle | ( |  | file | ) | `[private]`

Definition at line 380 of file ProcessJobOptions.py.

    00380                         :
    00381     import pickle
    00382     input = open(file, 'rb')
    00383     catalog = pickle.load(input)
    00384     _log.info('Unpickled %d configurables', len(catalog))
    00385
    def _import_opts(file):

def ProcessJobOptions::_import_python | ( |  | file | ) | `[private]`

Definition at line 377 of file ProcessJobOptions.py.

    00377                         :
    00378     execfile(file, {})
    00379
    def _import_pickle(file):

def ProcessJobOptions::_to_be_included | ( |  | f | ) | `[private]`

Definition at line 121 of file ProcessJobOptions.py.

    00121                       :
    00122     if f in _included_files:
    00123         _log.warning("file '%s' already included, ignored.", f)
    00124         return False
    00125     _included_files.add(f)
    00126     return True
    00127
    class JobOptsParser:

def ProcessJobOptions::GetConsoleHandler | ( |  | prefix = `None`,
|  |  | strm = `None` |
| ) |  |  |

Definition at line 83 of file ProcessJobOptions.py.

    00083                                                  :
    00084     global _consoleHandler
    00085     if _consoleHandler is None:
    00086         _consoleHandler = ConsoleHandler(prefix = prefix, strm = strm)
    00087     elif prefix is not None:
    00088         _consoleHandler.setPrefix(prefix)
    00089     return _consoleHandler
    00090
    def InstallRootLoggingHandler(prefix = None, level = None, strm = None):

def ProcessJobOptions::importOptions | ( |  | optsfile | ) |

Definition at line 395 of file ProcessJobOptions.py.

    00395                               :
    00396     # expand environment variables before checking the extension
    00397     optsfile = os.path.expandvars(optsfile)
    00398     # check the file type (extension)
    00399     dummy, ext = os.path.splitext(optsfile)
    00400     if ext in _import_function_mapping:
    00401         # check if the file has been already included
    00402         optsfile = _find_file(optsfile)
    00403         if _to_be_included(optsfile):
    00404             _log.info("--> Including file '%s'", optsfile)
    00405             # include the file
    00406             _import_function_mapping[ext](optsfile)
    00407             _log.info("<-- End of file '%s'", optsfile)
    00408     else:
    00409         raise ParserError("Unknown file type '%s' ('%s')" % (ext,optsfile))
    00410
    ## Import a file containing declaration of units.

def ProcessJobOptions::importUnits | ( |  | unitsfile | ) |

Import a file containing declaration of units.

It is equivalent to:

units "unitsfile.opts"

Definition at line 416 of file ProcessJobOptions.py.

    00416                           :
    00417     # expand environment variables
    00418     unitsfile = os.path.expandvars(unitsfile)
    00419     # we do not need to check the file type (extension) because it must be a
    00420     # units file
    00421     _parser._include(unitsfile, _parser._parse_units)
        _parser._include(unitsfile, _parser._parse_units)

def ProcessJobOptions::InstallRootLoggingHandler | ( |  | prefix = `None`,
|  |  | level = `None`,
|  |  | strm = `None` |
| ) |  |  |

Definition at line 91 of file ProcessJobOptions.py.

    00091                                                                        :
    00092     root_logger = logging.getLogger()
    00093     if not root_logger.handlers:
    00094         root_logger.addHandler(GetConsoleHandler(prefix, strm))
    00095         root_logger.setLevel(logging.WARNING)
    00096     if level is not None:
    00097         root_logger.setLevel(level)
    00098
    def PrintOn(step = 1, force = False):

def ProcessJobOptions::PrintOff | ( |  | step = `1` | ) |

Definition at line 101 of file ProcessJobOptions.py.

    00101                       :
    00102     GetConsoleHandler().printOff(step)
    00103
    class ParserError(RuntimeError):

def ProcessJobOptions::PrintOn | ( |  | step = `1`,
|  |  | force = `False` |
| ) |  |  |

Definition at line 99 of file ProcessJobOptions.py.

    00099                                     :
    00100     GetConsoleHandler().printOn(step, force)
    def PrintOff(step = 1):

## Variable Documentation

ProcessJobOptions::_consoleHandler = None

Definition at line 82 of file ProcessJobOptions.py.

dictionary ProcessJobOptions::_import_function_mapping

Initial value:

    {
                                 ".py"   : _import_python,
                                 ".pkl"  : _import_pickle,
                                 ".opts" : _import_opts,
                                }

Definition at line 389 of file ProcessJobOptions.py.

tuple ProcessJobOptions::_included_files = set()

Definition at line 120 of file ProcessJobOptions.py.

tuple ProcessJobOptions::_log = logging.getLogger(__name__)

Definition at line 4 of file ProcessJobOptions.py.

tuple ProcessJobOptions::_parser = JobOptsParser()

Definition at line 375 of file ProcessJobOptions.py.