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 |
Variables | |
tuple | _log = logging.getLogger(__name__) |
_consoleHandler = None | |
tuple | _included_files = set() |
tuple | _parser = JobOptsParser() |
dictionary | _import_function_mapping |
def ProcessJobOptions::GetConsoleHandler | ( | prefix = None |
) |
Definition at line 86 of file ProcessJobOptions.py.
00086 : 00087 global _consoleHandler 00088 if _consoleHandler is None: 00089 _consoleHandler = ConsoleHandler(prefix = prefix) 00090 elif prefix is not None: 00091 _consoleHandler.setPrefix(prefix) 00092 return _consoleHandler 00093 def InstallRootLoggingHandler(prefix = None, level = None):
def ProcessJobOptions::InstallRootLoggingHandler | ( | prefix = None , |
||
level = None | ||||
) |
Definition at line 94 of file ProcessJobOptions.py.
00094 : 00095 root_logger = logging.getLogger() 00096 if not root_logger.handlers: 00097 root_logger.addHandler(GetConsoleHandler(prefix)) 00098 root_logger.setLevel(logging.WARNING) 00099 if level is not None: 00100 root_logger.setLevel(level) 00101 def PrintOn(step = 1, force = False):
def ProcessJobOptions::PrintOn | ( | step = 1 , |
||
force = False | ||||
) |
def ProcessJobOptions::PrintOff | ( | step = 1 |
) |
Definition at line 104 of file ProcessJobOptions.py.
00104 : 00105 GetConsoleHandler().printOff(step) 00106 class ParserError(RuntimeError):
def ProcessJobOptions::_find_file | ( | f | ) | [private] |
Definition at line 110 of file ProcessJobOptions.py.
00110 : 00111 # expand environment variables in the filename 00112 f = os.path.expandvars(f) 00113 if os.path.isfile(f): 00114 return os.path.realpath(f) 00115 00116 path = os.environ.get('JOBOPTSEARCHPATH','').split(os.pathsep) 00117 # find the full path to the option file 00118 candidates = [d for d in path if os.path.isfile(os.path.join(d,f))] 00119 if not candidates: 00120 raise ParserError("Cannot find '%s' in %s" % (f,path)) 00121 return os.path.realpath(os.path.join(candidates[0],f)) 00122 _included_files = set()
def ProcessJobOptions::_to_be_included | ( | f | ) | [private] |
Definition at line 124 of file ProcessJobOptions.py.
00124 : 00125 if f in _included_files: 00126 _log.warning("file '%s' already included, ignored.", f) 00127 return False 00128 _included_files.add(f) 00129 return True 00130 class JobOptsParser:
def ProcessJobOptions::_import_python | ( | file | ) | [private] |
Definition at line 378 of file ProcessJobOptions.py.
00378 : 00379 execfile(file, {}) 00380 def _import_pickle(file):
def ProcessJobOptions::_import_pickle | ( | file | ) | [private] |
Definition at line 381 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)) 00386 def _import_opts(file):
def ProcessJobOptions::_import_opts | ( | file | ) | [private] |
Definition at line 387 of file ProcessJobOptions.py.
00387 : 00388 _parser.parse(file) 00389 _import_function_mapping = {
def ProcessJobOptions::importOptions | ( | optsfile | ) |
Definition at line 396 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)) 00411
tuple ProcessJobOptions::_log = logging.getLogger(__name__) [static] |
Definition at line 4 of file ProcessJobOptions.py.
ProcessJobOptions::_consoleHandler = None [static] |
Definition at line 85 of file ProcessJobOptions.py.
tuple ProcessJobOptions::_included_files = set() [static] |
Definition at line 123 of file ProcessJobOptions.py.
tuple ProcessJobOptions::_parser = JobOptsParser() [static] |
Definition at line 376 of file ProcessJobOptions.py.
dictionary ProcessJobOptions::_import_function_mapping [static] |
Initial value:
{ ".py" : _import_python, ".pkl" : _import_pickle, ".opts" : _import_opts, }
Definition at line 390 of file ProcessJobOptions.py.