예제 #1
0
    def initLogging(self, settings):
        # Create the config of the logging system
        if not settings['DisableLogFiles'] or settings['ForceLog']:
            lt = time.localtime()
            dateTime = f"{lt.tm_mday:02d}_{lt.tm_mon:02d}_{int(str(lt.tm_year)[-2:]):02d}-{lt.tm_hour:02d}_{lt.tm_min:02d}_{lt.tm_sec:02d}"

            logFile = os.path.join(settings['LogFolder'], 'PyLog' + dateTime + '.log')

            for handler in logging.root.handlers:
                logging.root.removeHandler(handler)

            logging.basicConfig(filename=logFile, level='INFO', format="%(message)s")

        if settings['Quiet'] is True:
            settings['VerboseLevel'] = 'Critical'

        # Setting up the verbose level
        if settings['VerboseLevel'] == 'Info':
            settings['vInfo'], settings['vDebug'], settings['vCritical'] = True, False, True
        elif settings['VerboseLevel'] == 'Debug':
            settings['vInfo'], settings['vDebug'], settings['vCritical'] = True, True, True
        elif settings['VerboseLevel'] == 'Critical':
            settings['vInfo'], settings['vDebug'], settings['vCritical'] = False, False, True
        elif settings['VerboseLevel'] == '':
            settings['vInfo'], settings['vDebug'], settings['vCritical'] = True, False, True
        else:
            print(f"Unknown VerboseLevel {settings['VerboseLevel']}... Setting it to 'Info'.")
            settings['vInfo'], settings['vDebug'], settings['vCritical'] = True, False, True

        pyLogger.init(logging.getLogger())
        pyLogger.initVerbose(settings)
예제 #2
0
def __loadFromTriggerPickle(fileName):
   """Helper function to retrieve a configuration from a pickle file produced by
   querying the trigger-db.
   Return the dictionary    { 'algs'     : [...],
                              'services' : [...],
                              'tools'    : [...],
                              'auditors' : [...] }
   """
   
   import os, shelve
   from Logging import logging
   msg = logging.getLogger('TriggerDbCfgLoader')

   try: _f = open(fileName,'r');_f.close(); del _f
   except Exception,err:
      msg.error(err)
      raise
예제 #3
0
# dictionary with configurable class : python module entries
import ConfigurableDb

### data ---------------------------------------------------------------------
__version__ = '2.0.0'
__author__ = 'Wim Lavrijsen ([email protected]), Martin Woudstra ([email protected])'

__all__ = [
    'PropertyProxy', 'GaudiHandlePropertyProxy',
    'GaudiHandleArrayPropertyProxy'
]

## for messaging
from Logging import logging
log = logging.getLogger('PropertyProxy')


def derives_from(derived, base):
    """A string version of isinstance().
   <derived> is either an object instance, or a type
   <base>    is a string containing the name of the base class (or <derived> class)"""
    if not isinstance(derived, type):
        derived = type(derived)

    if derived.__name__ == base:
        return True

    for b in derived.__bases__:
        if derives_from(b, base):
            return True
예제 #4
0
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration

# File: AthenaCommon/python/Help.py
# Author: Wim Lavrijsen ([email protected])
"""Basic end-user help."""

import os
from Logging import logging

### data ---------------------------------------------------------------------
__version__ = '1.0.0'
__author__ = 'Wim Lavrijsen ([email protected])'

__all__ = ['help']

log = logging.getLogger("AthenaHelp")
log.setLevel(logging.INFO)


### help text ----------------------------------------------------------------
class Topic:
    def __init__(self, id, title, text, web, action=None, super=None):
        self.id = id
        self.title = title
        self.text = text
        self.web = web
        self.action = action
        if not super and id:
            global book
            book.sub.append(self)
            self.super = book
예제 #5
0
# Note: load iProperty etc. from GaudiPython only as-needed
import GaudiKernel.GaudiHandles as GaudiHandles

### data ---------------------------------------------------------------------
__version__ = '3.2.0'
__author__ = 'Wim Lavrijsen ([email protected])'

__all__ = [
    'Configurable', 'ConfigurableAlgorithm', 'ConfigurablePyAlgorithm',
    'ConfigurableAlgTool', 'ConfigurableAuditor', 'ConfigurableService',
    'ConfigurableUser'
]

## for messaging
from Logging import logging
log = logging.getLogger('Configurable')


### base class for configurable Gaudi algorithms/services/algtools/etc. ======
class Configurable(object):
    """Base class for Gaudi components that implement the IProperty interface.
      Provides most of the boilerplate code, but the actual useful classes
      are its derived ConfigurableAlgorithm, ConfigurableService, and
      ConfigurableAlgTool."""

    ## for detecting the default name
    class DefaultName:
        pass

    propertyNoValue = '<no value>'
    indentUnit = '| '
예제 #6
0
# File: AthenaCommon/python/ResourceLimits.py
# Author: Grigori Rybkine ([email protected])
# Modified: Wim Lavrijsen ([email protected])
"""Helper to max soft resource limits to the hard ones."""

from Logging import logging
import resource

### data ---------------------------------------------------------------------
__version__ = '1.2.1'
__author__ = 'Grigori Rybkine ([email protected])'

__all__ = ['SetMaxLimits']

log = logging.getLogger('ResourceLimits')


### private helper -----------------------------------------------------------
def _maxout(what, descr):
    soft, hard = resource.getrlimit(what)
    if soft < hard or (hard == -1L and soft != hard):
        log.debug(
            'setting soft %s limit to %s (was: %s)',
            descr,
            hard == -1L and 'unlimited' or str(hard),
            soft == -1L and 'unlimited' or str(soft),
        )
        try:
            resource.setrlimit(what, (hard, hard))
        except ValueError, e:
            if what != resource.RLIMIT_AS or hard != -1L: raise
예제 #7
0
# dictionary with configurable class : python module entries
import ConfigurableDb


### data ---------------------------------------------------------------------
__version__ = '2.0.0'
__author__  = 'Wim Lavrijsen ([email protected]), Martin Woudstra ([email protected])'

__all__ = [ 'PropertyProxy',
            'GaudiHandlePropertyProxy',
            'GaudiHandleArrayPropertyProxy' ]

## for messaging
from Logging import logging
log = logging.getLogger( 'PropertyProxy' ) 


def derives_from( derived, base ):
   """A string version of isinstance().
   <derived> is either an object instance, or a type
   <base>    is a string containing the name of the base class (or <derived> class)"""
   if not isinstance( derived, type ):
      derived = type(derived)

   if derived.__name__ == base:
      return True

   for b in derived.__bases__:
      if derives_from( b,base ):
         return True
예제 #8
0
# Author: Grigori Rybkine ([email protected])
# Modified: Wim Lavrijsen ([email protected])

"""Helper to max soft resource limits to the hard ones."""

from Logging import logging
import resource


### data ---------------------------------------------------------------------
__version__ = '1.2.1'
__author__  = 'Grigori Rybkine ([email protected])'

__all__ = [ 'SetMaxLimits' ]

log = logging.getLogger( 'ResourceLimits' )


### private helper -----------------------------------------------------------
def _maxout( what, descr ):
   soft, hard = resource.getrlimit( what )
   if soft < hard or ( hard == -1L and soft != hard ):
      log.debug( 'setting soft %s limit to %s (was: %s)', descr,
                 hard == -1L and 'unlimited' or str(hard),
                 soft == -1L and 'unlimited' or str(soft), )
      try:
         resource.setrlimit( what, (hard,hard) )
      except ValueError, e:
         if what != resource.RLIMIT_AS or hard != -1L: raise
         import platform
         if platform.architecture()[0] != '32bit': raise