| The Gaudi Framework v32r1 (f65d50dc)

Classes | Functions | Variables
GaudiKernel.ProcessJobOptions Namespace Reference

## Classes
class | _TempSysPath
class | ConsoleHandler
class | JobOptsParser
class | LogFilter
class | LogFormatter
class | ParserError

## Functions
def | GetConsoleHandler (prefix=None, stream=None, with_time=False)
def | InstallRootLoggingHandler (prefix=None, level=None, stream=None, with_time=False)
def | PrintOn (step=1, force=False)
def | PrintOff (step=1)
def | _find_file (f)
def | _to_be_included (f)
def | _import_python (file)
def | _import_pickle (file)
def | _import_opts (file)
def | importOptions (optsfile)
def | importUnits (unitsfile)

## Variables
| _log = logging.getLogger(__name__)
| _consoleHandler = None
| _included_files = set()
| _parser = JobOptsParser()
dictionary | _import_function_mapping

## Function Documentation

## ◆ _find_file()

def GaudiKernel.ProcessJobOptions._find_file | ( |  | f | ) |
| private

Definition at line 140 of file ProcessJobOptions.py.

140 def _find_file(f):
141 # expand environment variables in the filename
142 f = os.path.expandvars(f)
143 if os.path.isfile(f):
144 return os.path.realpath(f)
145
146 path = os.environ.get('JOBOPTSEARCHPATH', '').split(os.pathsep)
147 # find the full path to the option file
148 candidates = [d for d in path if os.path.isfile(os.path.join(d, f))]
149 if not candidates:
150 raise ParserError("Cannot find '%s' in %s" % (f, path))
151 return os.path.realpath(os.path.join(candidates[0], f))
152
153
GaudiKernel.ProcessJobOptions._find_file
def _find_file(f)
Definition: ProcessJobOptions.py:140

## ◆ _import_opts()

def GaudiKernel.ProcessJobOptions._import_opts | ( |  | file | ) |
| private

Definition at line 468 of file ProcessJobOptions.py.

468 def _import_opts(file):
469 _parser.parse(file)
470
471
GaudiKernel.ProcessJobOptions._import_opts
def _import_opts(file)
Definition: ProcessJobOptions.py:468

## ◆ _import_pickle()

def GaudiKernel.ProcessJobOptions._import_pickle | ( |  | file | ) |
| private

Definition at line 461 of file ProcessJobOptions.py.

461 def _import_pickle(file):
462 import pickle
463 input = open(file, 'rb')
464 catalog = pickle.load(input)
465 _log.info('Unpickled %d configurables', len(catalog))
466
467
GaudiKernel.ProcessJobOptions._import_pickle
def _import_pickle(file)
Definition: ProcessJobOptions.py:461

## ◆ _import_python()

def GaudiKernel.ProcessJobOptions._import_python | ( |  | file | ) |
| private

Definition at line 457 of file ProcessJobOptions.py.

457 def _import_python(file):
458 execfile(file, {})
459
460
GaudiKernel.ProcessJobOptions._import_python
def _import_python(file)
Definition: ProcessJobOptions.py:457

## ◆ _to_be_included()

def GaudiKernel.ProcessJobOptions._to_be_included | ( |  | f | ) |
| private

Definition at line 157 of file ProcessJobOptions.py.

157 def _to_be_included(f):
158 if f in _included_files:
159 _log.warning("file '%s' already included, ignored.", f)
160 return False
161 _included_files.add(f)
162 return True
163
164
GaudiKernel.ProcessJobOptions._to_be_included
def _to_be_included(f)
Definition: ProcessJobOptions.py:157

## ◆ GetConsoleHandler()

def GaudiKernel.ProcessJobOptions.GetConsoleHandler | ( |  | prefix = `None`,
|  |  | stream = `None`,
|  |  | with_time = `False`
| ) |  |

Definition at line 106 of file ProcessJobOptions.py.

106 def GetConsoleHandler(prefix=None, stream=None, with_time=False):
107 global _consoleHandler
108 if _consoleHandler is None:
109 _consoleHandler = ConsoleHandler(
110 prefix=prefix, stream=stream, with_time=with_time)
111 elif prefix is not None:
112 _consoleHandler.setPrefix(prefix)
113 return _consoleHandler
114
115
GaudiKernel.ProcessJobOptions.GetConsoleHandler
def GetConsoleHandler(prefix=None, stream=None, with_time=False)
Definition: ProcessJobOptions.py:106

## ◆ importOptions()

def GaudiKernel.ProcessJobOptions.importOptions | ( |  | optsfile | ) |

Definition at line 479 of file ProcessJobOptions.py.

479 def importOptions(optsfile):
480 # expand environment variables before checking the extension
481 optsfile = os.path.expandvars(optsfile)
482 # check the file type (extension)
483 dummy, ext = os.path.splitext(optsfile)
484 if ext in _import_function_mapping:
485 # check if the file has been already included
486 optsfile = _find_file(optsfile)
487 if _to_be_included(optsfile):
488 _log.info("--> Including file '%s'", optsfile)
489 # include the file
490 _import_function_mapping[ext](optsfile)
491 _log.info("<-- End of file '%s'", optsfile)
492 else:
493 raise ParserError("Unknown file type '%s' ('%s')" % (ext, optsfile))
494
495
496 # Import a file containing declaration of units.
497 # It is equivalent to:
498 #
499 # #units "unitsfile.opts"
500 #
501
502
GaudiKernel.ProcessJobOptions._to_be_included
def _to_be_included(f)
Definition: ProcessJobOptions.py:157
GaudiKernel.ProcessJobOptions._find_file
def _find_file(f)
Definition: ProcessJobOptions.py:140
GaudiKernel.ProcessJobOptions.importOptions
def importOptions(optsfile)
Definition: ProcessJobOptions.py:479

## ◆ importUnits()

def GaudiKernel.ProcessJobOptions.importUnits | ( |  | unitsfile | ) |

Definition at line 503 of file ProcessJobOptions.py.

503 def importUnits(unitsfile):
504 # expand environment variables
505 unitsfile = os.path.expandvars(unitsfile)
506 # we do not need to check the file type (extension) because it must be a
507 # units file
508 _parser._include(unitsfile, _parser._parse_units)
GaudiKernel.ProcessJobOptions.importUnits
def importUnits(unitsfile)
Definition: ProcessJobOptions.py:503

## ◆ InstallRootLoggingHandler()

def GaudiKernel.ProcessJobOptions.InstallRootLoggingHandler | ( |  | prefix = `None`,
|  |  | level = `None`,
|  |  | stream = `None`,
|  |  | with_time = `False`
| ) |  |

Definition at line 116 of file ProcessJobOptions.py.

116 def InstallRootLoggingHandler(prefix=None,
117 level=None,
118 stream=None,
119 with_time=False):
120 root_logger = logging.getLogger()
121 if not root_logger.handlers:
122 root_logger.addHandler(GetConsoleHandler(prefix, stream, with_time))
123 root_logger.setLevel(logging.WARNING)
124 if level is not None:
125 root_logger.setLevel(level)
126
127
GaudiKernel.ProcessJobOptions.GetConsoleHandler
def GetConsoleHandler(prefix=None, stream=None, with_time=False)
Definition: ProcessJobOptions.py:106
GaudiKernel.ProcessJobOptions.InstallRootLoggingHandler
def InstallRootLoggingHandler(prefix=None, level=None, stream=None, with_time=False)
Definition: ProcessJobOptions.py:116

## ◆ PrintOff()

def GaudiKernel.ProcessJobOptions.PrintOff | ( |  | step = `1` | ) |

Definition at line 132 of file ProcessJobOptions.py.

132 def PrintOff(step=1):
133 GetConsoleHandler().printOff(step)
134
135
GaudiKernel.ProcessJobOptions.PrintOff
def PrintOff(step=1)
Definition: ProcessJobOptions.py:132
GaudiKernel.ProcessJobOptions.GetConsoleHandler
def GetConsoleHandler(prefix=None, stream=None, with_time=False)
Definition: ProcessJobOptions.py:106

## ◆ PrintOn()

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

Definition at line 128 of file ProcessJobOptions.py.

128 def PrintOn(step=1, force=False):
129 GetConsoleHandler().printOn(step, force)
130
131
GaudiKernel.ProcessJobOptions.GetConsoleHandler
def GetConsoleHandler(prefix=None, stream=None, with_time=False)
Definition: ProcessJobOptions.py:106
GaudiKernel.ProcessJobOptions.PrintOn
def PrintOn(step=1, force=False)
Definition: ProcessJobOptions.py:128

## Variable Documentation

## ◆ _consoleHandler

GaudiKernel.ProcessJobOptions._consoleHandler = None
| private

Definition at line 103 of file ProcessJobOptions.py.

## ◆ _import_function_mapping

dictionary GaudiKernel.ProcessJobOptions._import_function_mapping
| private

Initial value:
1 = {
2 ".py": _import_python,
3 ".pkl": _import_pickle,
4 ".opts": _import_opts,
5 }

Definition at line 472 of file ProcessJobOptions.py.

## ◆ _included_files

GaudiKernel.ProcessJobOptions._included_files = set()
| private

Definition at line 154 of file ProcessJobOptions.py.

## ◆ _log

GaudiKernel.ProcessJobOptions._log = logging.getLogger(__name__)
| private

Definition at line 7 of file ProcessJobOptions.py.

## ◆ _parser

GaudiKernel.ProcessJobOptions._parser = JobOptsParser()
| private

Definition at line 454 of file ProcessJobOptions.py.