| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Classes | Functions | Variables

# 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.

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

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

Definition at line 386 of file ProcessJobOptions.py.

    00387                       :
    00388     _parser.parse(file)

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

Definition at line 380 of file ProcessJobOptions.py.

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

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

Definition at line 377 of file ProcessJobOptions.py.

    00378                         :
    00379     execfile(file, {})

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

Definition at line 121 of file ProcessJobOptions.py.

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

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

Definition at line 83 of file ProcessJobOptions.py.

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

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

Definition at line 395 of file ProcessJobOptions.py.

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

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.

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

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

Definition at line 91 of file ProcessJobOptions.py.

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

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

Definition at line 101 of file ProcessJobOptions.py.

    00102                       :
    00103     GetConsoleHandler().printOff(step)

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

Definition at line 99 of file ProcessJobOptions.py.

    00100                                     :
        GetConsoleHandler().printOn(step, force)

## Variable Documentation

ProcessJobOptions::_consoleHandler = None

Definition at line 82 of file ProcessJobOptions.py.

dictionary ProcessJobOptions::_import_function_mapping

Initial value:

    00001 {
    00002                              ".py"   : _import_python,
    00003                              ".pkl"  : _import_pickle,
    00004                              ".opts" : _import_opts,
    00005                             }

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.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines