| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
GaudiKernel.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 GaudiKernel.ProcessJobOptions._find_file | ( |  | f | ) |
| private

Definition at line 107 of file ProcessJobOptions.py.

107
108 def _find_file(f):
109 # expand environment variables in the filename
110 f = os.path.expandvars(f)
111 if os.path.isfile(f):
112 return os.path.realpath(f)
113
114 path = os.environ.get('JOBOPTSEARCHPATH','').split(os.pathsep)
115 # find the full path to the option file
116 candidates = [d for d in path if os.path.isfile(os.path.join(d,f))]
117 if not candidates:
118 raise ParserError("Cannot find '%s' in %s" % (f,path))
119 return os.path.realpath(os.path.join(candidates[0],f))

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

Definition at line 386 of file ProcessJobOptions.py.

386
387 def _import_opts(file):
388 _parser.parse(file)

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

Definition at line 380 of file ProcessJobOptions.py.

380
381 def _import_pickle(file):
382 import pickle
383 input = open(file, 'rb')
384 catalog = pickle.load(input)
385 _log.info('Unpickled %d configurables', len(catalog))

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

Definition at line 377 of file ProcessJobOptions.py.

377
378 def _import_python(file):
379 execfile(file, {})

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

Definition at line 121 of file ProcessJobOptions.py.

121
122 def _to_be_included(f):
123 if f in _included_files:
124 _log.warning("file '%s' already included, ignored.", f)
125 return False
126 _included_files.add(f)
127 return True

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

Definition at line 83 of file ProcessJobOptions.py.

83
84 def GetConsoleHandler(prefix = None, stream = None):
85 global _consoleHandler
86 if _consoleHandler is None:
87 _consoleHandler = ConsoleHandler(prefix = prefix, stream = stream)
88 elif prefix is not None:
89 _consoleHandler.setPrefix(prefix)
90 return _consoleHandler

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

Definition at line 395 of file ProcessJobOptions.py.

395
396 def importOptions( optsfile ) :
397 # expand environment variables before checking the extension
398 optsfile = os.path.expandvars(optsfile)
399 # check the file type (extension)
400 dummy, ext = os.path.splitext(optsfile)
401 if ext in _import_function_mapping:
402 # check if the file has been already included
403 optsfile = _find_file(optsfile)
404 if _to_be_included(optsfile):
405 _log.info("--> Including file '%s'", optsfile)
406 # include the file
407 _import_function_mapping[ext](optsfile)
408 _log.info("<-- End of file '%s'", optsfile)
409 else:
410 raise ParserError("Unknown file type '%s' ('%s')" % (ext,optsfile))

def GaudiKernel.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.

416
417 def importUnits(unitsfile):
418 # expand environment variables
419 unitsfile = os.path.expandvars(unitsfile)
420 # we do not need to check the file type (extension) because it must be a
421 # units file
422 _parser._include(unitsfile, _parser._parse_units)

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

Definition at line 91 of file ProcessJobOptions.py.

91
92 def InstallRootLoggingHandler(prefix = None, level = None, stream = None):
93 root_logger = logging.getLogger()
94 if not root_logger.handlers:
95 root_logger.addHandler(GetConsoleHandler(prefix, stream))
96 root_logger.setLevel(logging.WARNING)
97 if level is not None:
98 root_logger.setLevel(level)

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

Definition at line 101 of file ProcessJobOptions.py.

101
102 def PrintOff(step = 1):
103 GetConsoleHandler().printOff(step)

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

Definition at line 99 of file ProcessJobOptions.py.

99
100 def PrintOn(step = 1, force = False):
GetConsoleHandler().printOn(step, force)

## Variable Documentation

GaudiKernel.ProcessJobOptions._consoleHandler None

Definition at line 82 of file ProcessJobOptions.py.

dictionary GaudiKernel.ProcessJobOptions._import_function_mapping

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

Definition at line 389 of file ProcessJobOptions.py.

tuple GaudiKernel.ProcessJobOptions._included_files set()

Definition at line 120 of file ProcessJobOptions.py.

tuple GaudiKernel.ProcessJobOptions._log logging.getLogger(__name__)

Definition at line 4 of file ProcessJobOptions.py.

tuple GaudiKernel.ProcessJobOptions._parser JobOptsParser()

Definition at line 375 of file ProcessJobOptions.py.