Skip to content
Snippets Groups Projects
Commit 11b2dc58 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'master-remove-DCubeClient' into 'master'

Remove DCubeClient package

See merge request !32450
parents 27525ff0 7d003534
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!32450Remove DCubeClient package
Showing
with 0 additions and 7429 deletions
################################################################################
# Package: DCubeClient
################################################################################
# Declare the package name:
atlas_subdir( DCubeClient )
# Install files from the package:
atlas_install_python_modules( python/*.py )
atlas_install_joboptions( share/DCubeClient_jobOptions.py )
atlas_install_runtime( test/DCubeClient_TestConfiguration.xml test/*.C share/DCubeValid.xml share/DCubeServer )
atlas_install_scripts( python/dcube.py python/dcubeConvert.py )
atlas_install_xmls( share/DCubeValid.xml )
<!--
file: DCubeForRTTCfg.xml
brief: DCubeClient for AtlasRTT ini file
author: Krzysztof Daniel Ciba
date: Sep 4, 2007
* Oct 23, 2007 - cibak - switch to root 5.17/04
* Apr 10, 2008 - cibak - switch to root 5.19/02, python 2.5, DCubeServer-00-00-10
* Aug 14, 2009 - cibak - switch to root 5.22/00d
* Oct 06, 2009 - cibak - switch to root 5.25/02
* Feb 15, 2010 - cibak - swicth to root 5.26.00b
-->
<init version="3.1.4.1.5">
<!-- runtime parameters -->
<!-- base directory with reference files -->
<ref_dir>/afs/cern.ch/atlas/project/RTT/prod/Results/reference/</ref_dir>
<!-- base directory with dcube server installation -->
<server>/afs/cern.ch/atlas/project/RTT/prod/Results/dcube/latest/</server>
</init>
<!-- end of DCubeForRTTCfg.xml file -->
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
##
# @module DCubeRunner
# @author Krzysztof Daniel Ciba
# @date 4 Sep 2007
# @brief Glue module to plugin DCube to Atlas RTT.
#
# * Feb 4, 2007 - switch to DCubeClient-00-00-13
# and DCubeServer-00-00-08
# * Apr 10, 2008 - switch to DCubeServer-00-00-10
# * Nov 7, 2008 - switch to new DCubeServer-00-00-11
# * Nov 11, 2008 - switch to new DCubeClient-00-00-19 and DCubeServer-00-00-12
#
## some imports
import xml.dom.minidom as minidom
import os, sys
import os.path
import re
## @class DCubeRunner
# @brief prepares and runs shell script with DCube command
class DCubeRunner:
## DCubeClient API classes
__reAPIClasses = [ re.compile("DCubeApp"),
re.compile("DCubeConfig"),
re.compile("DCubeTester"),
re.compile("DCubePlotter"),
re.compile("DCubePHPWriter") ]
## base directory for references
baseRef = "/afs/cern.ch/atlas/project/RTT/prod/Results/reference/"
## DCubeServer directory
dcubeServer = "/afs/cern.ch/atlas/project/RTT/prod/Results/dcube/latest/"
## DCubeClient directory
dcubeClient = "/afs/cern.ch/atlas/project/RTT/DCubeClient/latest/python"
## c'tor
# @param self "Me, myself and Irene"
# @param argDict RTT action runner dictionary
def __init__( self, argDict={} ):
try:
from Logger import Logger
self.logger = Logger()
except ImportError:
self.logger = False
self.error = None
self.debug("DCubeRunner constructor is getting args from dictionary...")
self.cfgFile = None
if ( "DCubeCfg" in argDict ):
self.cfgFile = argDict["DCubeCfg"]
else:
self.info( "*** No DCubeCfg in DCubeRunner action dictionary ***" )
self.error = "No DCubeCfg in DCubeRunner argDict"
self.refFile = None
if ( "DCubeRef" in argDict ):
self.refFile = argDict["DCubeRef"]
else:
self.info( "*** No DCubeRef in DCubeRunner action dictionay, will use value from config XML file ***" )
self.monFile = None
if ( "DCubeMon" in argDict ):
self.monFile = argDict["DCubeMon"]
else:
self.info( "*** No DCubeMon in DCubeRunner action dictionary ***" )
self.error = "No DCubeMon in DCubeRunner argDict"
if ( "DCubeJobId" in argDict ):
self.jobId = argDict["DCubeJobId"]
else:
self.jobId = None
jobDtor = argDict.get('JobDescriptor', None )
if ( jobDtor != None ):
self.DCubeForRTTCfg = jobDtor.paths.dCubeCfgFile
self.outputPath = jobDtor.runPath
self.installArea = jobDtor.paths.installArea
self.cvsPath = 'offline/' + jobDtor.paths.containerPackage
self.cmtPath = jobDtor.paths.cmtPath
self.nightly = jobDtor.paths.branch # branch
self.install = jobDtor.paths.runType # install
self.cmtconfig = jobDtor.paths.cmtConfig # CMTCONFIG
self.project = jobDtor.paths.topProject # Atlas project name
self.release = jobDtor.paths.release # release name
else:
## dummy values for testing
self.DCubeForRTTCfg = "./DCubeForRTTCfg.xml"
self.outputPath = "./"
self.installArea = "./"
self.cvsPath = "offline/Tools/DCubeClient"
self.cmtPath = "."
self.nightly = "dev"
self.install = "build"
self.cmtconfig = "i686-slc5-gcc43-opt"
self.project = "AtlasProduction"
self.release = "rel_1"
self.debug("[01] will use '%s' as DCubeClient configuration file for RTT" % self.DCubeForRTTCfg )
self.debug("[02] will use '%s' as output path" % self.outputPath )
self.debug("[03] will use '%s' as install area path" % self.installArea )
self.debug("[04] will use '%s' as package CVS path" % self.cvsPath )
self.debug("[05] will use '%s' as cmt path" % self.cmtPath )
self.debug("[06] will use DCubeClient monitored file '%s'" % self.monFile )
self.debug("[07] will use DCubeClient reference file '%s'" % self.refFile )
self.debug("[08] will use DCubeClient configuration file '%s'" % self.cfgFile )
self.debug("[09] will use '%s' as DCubeClient branch name" % self.nightly )
self.debug("[10] will use '%s' as DCubeClient install name" % self.install )
self.debug("[11] will use '%s' as DCubeClient cmtconfig name" % self.cmtconfig )
self.debug("[12] will use '%s' as DCubeClient project name" % self.project )
if ( self.jobId ):
self.debug("[13] will use '%s' as DCubeClient jobId" % self.jobId )
else:
self.debug("[13] DCubeClient jobId not set!")
self.command = [ ]
if ( self.error == None ):
for line in self.__parseDCubeRTTCfg():
self.command.append( line )
msg = "command to run is:\n"+20*"-"+"\n"
for line in self.command:
msg += line
msg += "\n"+20*"-"+"\n"
self.debug( msg )
self.debug( "DCubeRunner is ready to work...")
## run method
# @param self "Me, myself and Irene"
def run( self ):
if ( self.error == None ):
try:
from ShellCommand import ShellCommand
# FIXME - self.logger could be just python False...
sc = ShellCommand( self.command,
self.logger )
replay = sc.getReply()
reLine = re.compile("OVERALL STATISTICS STATUS")
status = 1
for line in replay:
for apiClass in self.__reAPIClasses:
if ( apiClass.search( line ) ):
self.debug( line )
if ( reLine.search( line ) ):
if ( "OK" in line ): status = 0
return status
except ImportError:
self.info("No ShellCommand in PYTHONPATH! 'No Cin-Cin, no run...'")
return 1
else:
self.info(self.error)
return 1
## XML parsing of DCubeForRTTCfg.xml
# @param self "Me, myself and Irene"
def __parseDCubeRTTCfg( self ):
self.debug( "parsing DCubeRunner configuration file %s" % self.DCubeForRTTCfg )
try:
xmldoc = minidom.parse( self.DCubeForRTTCfg )
self.refBaseDir = self.getText( xmldoc.getElementsByTagName("ref_dir")[0].childNodes )
self.debug( "[14] will use '%s' as base reference directory" % self.refBaseDir )
self.dcubeServer = self.getText( xmldoc.getElementsByTagName("server")[0].childNodes )
self.debug( "[15] will use DCubeServer installed in %s" % self.dcubeServer )
except:
self.error = "error when parsing DCubeRunner configuration file, no run will be preformed"
return [ "" ]
self.debug("constructing command to run DCube...")
out = [ ]
words = self.cmtconfig.split("-")
if ( words[0] == "i686" ):
bin = "32"
else:
bin = "64"
gcc = words[2]
opt = words[3]
tag = ",".join( [self.release, self.nightly, bin, gcc, opt, self.project, "forceConfig" ])
out.append("export CMTCONFIG="+self.cmtconfig+"\n")
out.append("source ~/cmthome/setup.sh -tag=%s\n" % ( tag ) )
out.append( "export PATH=" + self.dcubeClient + ":${PATH}\n")
out.append( "export PYTHONPATH=" + self.dcubeClient + ":${PYTHONPATH}\n")
# changing the outputPath
monPath = self.outputPath
self.outputPath = self.outputPath + os.sep + "DCube-" + self.refFile
# creating DCube subdirectory
out.append("mkdir -p " + self.outputPath + "\n")
dcubePath = self.dcubeClient
dcubeConvert = os.path.join( dcubePath, "./dcubeConvert.py")
run = os.path.join(dcubePath,"./dcube.py")
run += " -p " # generate plot
run += " --branch " + self.nightly # set branch
run += " --install " + self.install # set install
run += " --cmtconfig " + self.cmtconfig # set cmtconfig
run += " --project " + self.project # set project
# set jobId
if ( self.jobId ):
run += " --jobId " + self.jobId
run += " -l " + self.outputPath + os.sep + self.monFile + ".dcube.log" # save log to monitored.dcube.log
run += " -s " + self.dcubeServer # path to the DCubeServer installation
run += " -x " + self.outputPath + os.sep + self.monFile + ".dcube.xml " # save output to monitored.dcube.xml
# dangerous hacking at the moment...
if ( os.path.isabs( self.cfgFile ) or "DUMMY-TEST" in self.cfgFile ):
run += " -c " + self.cfgFile
config = self.cfgFile
else:
# checking cfg file in reference dir
refCfg = "/afs/cern.ch/atlas/project/RTT/Results/reference/" + self.cvsPath + os.sep + self.cfgFile
self.debug("will check the timestamp of DCube configuration file (reference volume): " + refCfg )
refCfgStat = None
if ( os.path.exists(refCfg) ):
refCfgStat = os.stat(refCfg)
self.debug("File %s modified %d" %( refCfg, refCfgStat[8]) )
else:
self.debug("DCube configuration file %s not found on 'reference' volume" % self.cfgFile )
# checking cfg file in cvs co dir
cvsCfg = self.cmtPath + os.sep + self.cvsPath.lstrip("offline") + "/test/" + self.cfgFile
self.debug("will check the timestamp of DCube configuration file (CVS checkout volume):" + cvsCfg)
cvsCfgStat = None
if ( os.path.exists(cvsCfg) ) :
cvsCfgStat = os.stat( cvsCfg )
self.debug("File %s modified %d" %( cvsCfg, cvsCfgStat[8]) )
else:
self.debug("DCube configuration file %s not found in CVS checkout directory" % self.cfgFile )
# choose configuration file based on latest timestamp
config = None
# both are present, check time stamps
if ( None not in ( refCfgStat, cvsCfgStat) ):
# install area newer
if ( refCfgStat[8] <= cvsCfgStat[8] ):
config = cvsCfg
else:
config = refCfg
# reference is present
elif ( None != refCfgStat ):
config = refCfg
# install area is present
elif ( None != cvsCfgStat ):
config = cvsCfg
# both are absent
else:
pass
if ( config != None ):
run += " -c " + config # add configuration file
else:
self.debug("DCube configuration file %s not found on afs reference volume or InstallArea directories" % self.cfgFile )
return [ "" ]
if ( self.refFile != None ):
run += " -r " + os.path.join( os.path.join(self.refBaseDir , self.cvsPath) , self.refFile ) # overwrite reference
run += " " + os.path.join( monPath , self.monFile) # add monitored file at the end
if ( "DUMMY-TEST" in self.cfgFile ):
dcubeConvert += " %s " % os.path.abspath(self.cfgFile)
else:
dcubeConvert += " %s " % os.path.abspath(config)
dcubeConvert += " %s\n" % os.path.join( os.path.join(self.refBaseDir , self.cvsPath) , self.refFile )
out.append( dcubeConvert )
out.append( run + "\n")
return out
## logger level INFO
# @param self "Me, myself and Irene"
# @param msg message
def info( self, msg ):
if ( bool(self.logger) ):
self.logger.info( str(msg) )
else:
print "DCubeRunner INFO " + str(msg)
## logger level DEBUG
# @param self "Me, myself and Irene"
# @param msg message
def debug( self, msg ):
if ( bool(self.logger) ):
self.logger.debug( str( msg) )
else:
print "DCubeRunner DEBUG " + str(msg)
## get CDATA section
# @param self "me, myself and Irene"
# @param nodelist list of XML DOM Nodes
def getText( self, nodelist ):
out = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
out = out + node.data
return out
## split path
# @param self "Me, myself and Irene"
# @param path path to split
# @param rest splitted tail
def pathSplit(self, path, rest=[] ):
( head , tail ) = os.path.split( path )
if len(head) < 1: return [tail]+ rest
if len(tail) < 1: return [head]+ rest
return self.pathSplit( head, [tail] + rest )
## find common names in path
# @param self "Me, myself and Irene"
# @param l1 first list with splitted path
# @param l2 second lust with splitted path
# @param common list of common dirnames
def commonPath(self, l1, l2, common=[] ):
if len(l1) < 1: return (common, l1, l2)
if len(l2) < 1: return (common, l1, l2)
if l1[0] != l2[0]: return (common, l1, l2)
return self.commonPath( l1[1:], l2[1:], common+[l1[0]])
## finds relative path between p1 and p2
# @param self "Me, myself and Irene"
# @param p1 first path
# @param p2 second path
def relPath(self, p1, p2):
( common, l1, l2 ) = self.commonPath( self.pathSplit(p1), self.pathSplit(p2))
p = []
if len(l1) > 0:
p = [ '../' * len(l1) ]
p = p + l2
return os.path.join( *p )
## dummy test running
if __name__ == "__main__":
print "running DCubeRunner..."
testCfg = { "DCubeCfg" : "test_dcube_cfg.xml",
"DCubeMon" : "monitored.root",
"DCubeRef" : "reference.root",
"DCubeJobId" : "test_01",
"JobDescriptor" : None }
dc = DCubeRunner( testCfg )
dc.run()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
##
# @file DCubeClient/python/DCubePHPWriter.py
# @author Krzyszotf Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)
# @brief implementation of DCubePHPWriter and test_DCubePHPWriter classes
import sys
import os
from time import strftime, localtime, strptime
from DCubeUtils import DCubeObject, DCubeException, DCubeVersion
from DCubeOptParser import DCubeOptParser
import unittest
##
# @class DCubePHPWriter
# @author Krzysztof Daniel Ciba (Krzytof.Ciba@NOSPAMgmail.com)
# @brief PHP files producer
class DCubePHPWriter( DCubeObject ):
## c'tor
# @param self "My, myself and Irene"
# @param parsed opts and args from DCubeOptParser
def __init__( self, parsed ):
super( DCubePHPWriter, self ).__init__( self )
self.opts, self.args = parsed
## give relative path between target and base
# @param self "Me, myself and Irene"
# @param target target directory name
# @param base base directory name
def __relpath( self, target, base="." ):
if ( not os.path.exists(target) ):
self.error( "target directory %s does not exist" % target )
if ( not os.path.isdir(base) ):
self.warn( "base %s is not a directory or does not exist" % base )
base_list = (os.path.abspath(base)).split(os.sep)
target_list = (os.path.abspath(target)).split(os.sep)
for i in range(min(len(base_list), len(target_list))):
if base_list[i] != target_list[i]: break
else:
i+=1
rel_list = [os.pardir] * (len(base_list)-i) + target_list[i:]
return os.path.join(*rel_list)
## php heading string
# @param self "Me, myself and Irene"
def __head( self ):
return "<?php\n"
## php tail string
# @param self "Me, myself and Irene"
def __tail( self ):
return "?>\n"
## php comment string
# @param self "Me, myself and Irene"
def __comment( self, what="output" ):
out = "/**\n"
out += " * DCubeClient PHP %s file\n" % what
out += " * autogenerated using %s\n" % DCubeVersion().version()
out += " * on %s\n" % strftime("%a, %d %b %Y %H:%M:%S %Z" , localtime())
out += " * Files:\n"
out += " * [1] monitored file = %s\n" % str( self.opts.monitored )
out += " * [2] reference file = %s\n" % str( self.opts.reference )
out += " * [3] config XML file = %s\n" % str( self.opts.config )
out += " * [4] output XML file = %s\n" % str( self.opts.output )
out += " * [5] log file = %s\n" % str( self.opts.log )
out += " *\n"
out += " * ***************************************************\n"
out += " * * !!! WARNINIG !!! *\n"
out += " * * make sure that dcube.php is in PHP include path *\n"
out += " * ***************************************************\n"
out += " *\n"
out += " *\n"
out += " * ***************************************************\n"
out += " * * !!! WARNINIG !!! *\n"
out += " * * make sure to put relative path from your result *\n"
out += " * * directory to the the directory with dcube.php *\n"
out += " * ***************************************************\n"
out += " *\n"
return out
## body of output PHP file
# @param self "Me, myself and Irene"
def __bodyPHP( self ):
out = "/* ADD TO include_path TO LOCAL INSTALLATION OF DCUBE PHP PART */\n"
out += "$where = \"DCubeServer\";\n"
out += "set_include_path($where);\n";
out += "require \"dcube.php\";\n\n";
out += "$xml_file = \"%s\";\n" % os.path.basename(self.opts.output)
out += "$log_file = \"%s\";\n" % os.path.basename(self.opts.log )
out += "$dcube = new dcube( $xml_file, $log_file, $where );\n"
return out
## body for log php file
# @param self "Me, myself and Irene"
def __bodyLOG( self ):
out = "/* ADD TO include_path TO LOCAL INSTALLATION OF DCUBE PHP PART */\n";
out += "$where = \"DCubeServer\";\n"
out += "set_include_path($where);\n"
out += "require \"rw.php\";\n\n"
out += "$log_file = \"%s\";\n" % os.path.basename(self.opts.log)
out += "$page = new rainbow( $log_file );\n"
return out
## dcube output PHP file contents
# @param self "Me, myself and Irene"
def dcubePHP( self ):
out = self.__head()
out += self.__comment()
out += self.__bodyPHP()
out += self.__tail()
return out
## dcube log PHP file contents
# @param self "Me, myself and Irene"
def dcubeLOG( self ):
out = self.__head()
out += self.__comment( "log" )
out += self.__bodyLOG()
out += self.__tail()
return out
##
# @class test_DCubePHPWriter
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)
# @brief test case for DCubePHPWriter class
class test_DCubePHPWriter( unittest.TestCase ):
## test case setup
# @param self "Me, myself and Irene"
def setUp( self ):
sys.argv = [__file__, "-r", "testRef.root", "-s", "/path/to/server/", "-x", "output.xml", "montitored.root" ]
self.parsed = DCubeOptParser().parse( sys.argv )
self.parsed[0]._update_loose( { "monitored" : "monitored.root" } )
## c'tor
# @param self "Me, myself and Irene"
def test_01_ctor( self ):
try:
self.phpWriter = DCubePHPWriter( self.parsed )
except:
pass
self.assertEqual( isinstance(self.phpWriter, DCubePHPWriter), True)
## dcubePHP nad dcubeLOG
# @param self "Me, myself and Irene"
def test_02_writer( self ):
phpWriter = DCubePHPWriter( self.parsed )
print(phpWriter.dcubePHP( ))
print(phpWriter.dcubeLOG( ))
## test suite execution
if __name__ == "__main__":
testLoader = unittest.TestLoader()
suite = testLoader.loadTestsFromTestCase(test_DCubePHPWriter)
unittest.TextTestRunner(verbosity=3).run(suite)
This diff is collapsed.
This diff is collapsed.
#!/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
##
# @file DCubeClient/python/DCubeUtils.py
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)
# @brief Utility classes for DCubeApp
#
import xml.dom.minidom
import logging
import os
import sys
from types import *
import unittest
##
# @class Singleton
# @author Krzysztof Daniel Ciba (Kerzysztof.Ciba@NOSPAMgmail.com)
# @brief Forcing singleton type for python class instance.
class DCubeSingleton( type ):
## c'tor
# @param cls class instance
# @param name class name
# @param bases base classes
# @param dic parameters dictionary
def __init__(cls, name, bases, dic):
super( DCubeSingleton, cls ).__init__( name, bases, dic )
cls.instance = None
## call operator
# @param cls class instance
# @param *args unnamed arguments
# @param **kw keyword arguments
def __call__( cls, *args, **kw ):
if cls.instance is None:
cls.instance = super( DCubeSingleton, cls ).__call__( *args, **kw )
return cls.instance
##
# @class DCubeLogger
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAgmail.com)
# @brief DCube customized logger
class DCubeLogger( object ):
## metaclass type
__metaclass__ = DCubeSingleton
## reference to original logger instance
__log = None
## name of the log file
__logFile = None
## default name of the log file
__defaultLogFile = "./dcube.log"
## flag to trigger stdout print outs
__console = None
## logging levels
__levels = { "CRITICAL": logging.CRITICAL,
"ERROR": logging.ERROR,
"WARNING" : logging.WARNING,
"INFO" : logging.INFO,
"DEBUG" : logging.DEBUG }
## c'tor
# @brief c'tor
# @param self "Me, myself and Irene"
# @param fileName name of log file
# @param logName name of logger
# @param toConsole flag to trigger stdout printout
def __init__( self, fileName=None, logName="DCube", toConsole=True, verbosity=1 ):
if ( fileName == None ): fileName = self.__defaultLogFile
self.__logFile = os.path.abspath( fileName )
logging.basicConfig( level=logging.DEBUG,
format='%(name)-12s %(asctime)s %(levelname)-8s: %(message)s',
filename=fileName,
filemode='w' )
self.toConsole( toConsole, verbosity )
self.__log = logging.getLogger( str(logName) )
## save stdout and stderr handle
#self.__stdout = sys.stdout
#self.__stderr = sys.stderr
##
# @brief set logging level
# @param cls class reference
# @param level string with level name
@classmethod
def setLevel(cls, level="DEBUG"):
if ( level in cls.__levels.keys() ):
cls.__log.setLevel( cls.__levels[level] )
##
# @brief log file name getter
# @param cls class reference
# @return name of log file
def getFileName( self ):
return self.__logFile
##
# @brief logger getter
# @param cls class reference
# @param caller who call me?
@classmethod
def getLogger( cls, caller ):
logName = caller.__class__.__name__
cls.__log = logging.getLogger( logName )
return cls
## add/remove logging to the stdout and stderr
# @param cls class reference
# @param toConsole bool flag [default True]
@classmethod
def toConsole( cls, toConsole=True, verbosity=1 ):
if ( toConsole ):
if ( not isinstance(cls.__console, logging.StreamHandler) ):
cls.__console = logging.StreamHandler()
cls.__console.setLevel(verbosity*10)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
cls.__console.setFormatter(formatter)
logging.getLogger('').addHandler( cls.__console )
else:
if ( isinstance(cls.__console, logging.StreamHandler) ):
logging.getLogger('').removeHandler( cls.__console )
##
# @brief debug level logger
# @param cls class reference
# @param msg message to log
@classmethod
def debug( cls, msg ):
cls.__log.debug( msg )
##
# @brief info level logger
# @param cls class reference
# @param msg message to log
@classmethod
def info( cls, msg ):
cls.__log.info( msg )
##
# @brief info level logger, but always print (if verbosity<=2)
# @param cls class reference
# @param msg message to log
@classmethod
def infoExtra( cls, lines, verbosity=2 ):
oldlevel = None
if ( isinstance(cls.__console, logging.StreamHandler) ):
oldlevel = cls.__console.level
cls.__console.setLevel(verbosity*10)
for msg in lines:
cls.__log.info( str(msg) )
if oldlevel is not None:
cls.__console.setLevel(oldlevel)
##
# @brief warning level logger
# @param cls class reference
# @param msg message to log
@classmethod
def warn( cls, msg ):
cls.__log.warning( msg )
##
# @brief error level logger
# @param cls class reference
# @param msg message to log
@classmethod
def error( cls, msg ):
cls.__log.error( msg )
##
# @brief critical level logger
# @param cls class reference
# @param msg message to log
@classmethod
def panic( cls, msg ):
cls.__log.critical( msg )
##
# @brief critical level logger
# @param cls class reference
# @param msg message to log
@classmethod
def critical( cls, msg ):
cls.__log.critical( msg )
##
# @brief exception level logger
# @param cls class reference
# @param msg message to log
@classmethod
def exception( cls, msg ):
cls.__log.exception( msg )
##
# @brief exception level logger
# @param cls class reference
# @param msg message to log
@classmethod
def epanic( cls, msg ):
cls.__log.exception( msg )
##
# @class DCubeObject
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)
# @brief base class for all DCube classes
class DCubeObject( DCubeLogger ):
## c'tor
# @param self "Me, myself and Irene"
# @param caller reference to inherited object
def __init__( self, caller ):
## setting up logger
self.__log = DCubeLogger.getLogger( caller )
## debug level logger
# @param self "Me, myself and Irene"
# @param msg logging string
def debug( self, msg ):
try:
self.__log.getLogger(self).debug( str(msg) )
except AttributeError:
pass
## info level logger
# @param self "Me, myself and Irene"
# @param msg logging string
def info( self, msg ):
try:
self.__log.getLogger(self).info( str(msg) )
except AttributeError:
pass
## info level logger, but always print (if verbosity<=2)
# @param self "Me, myself and Irene"
# @param lines list of logging strings
def infoExtra( self, lines, verbose=2 ):
try:
self.__log.getLogger(self).infoExtra( lines, verbose )
except AttributeError:
for msg in lines:
print( str(msg) )
## warning level logger
# @param self "Me, myself and Irene"
# @param msg logging string
def warn( self, msg ):
try:
self.__log.getLogger(self).warn( str(msg) )
except AttributeError:
print(msg)
## error level logger
# @param self "Me, myself and Irene"
# @param msg logging string
def error( self, msg ):
try:
self.__log.getLogger(self).error( str(msg) )
except AttributeError:
print(msg)
## critical level logger
# @param self "Me, myself and Irene"
# @param msg logging string
def panic( self, msg ):
try:
self.__log.getLogger(self).critical( str(msg) )
except AttributeError:
print(msg)
## exception level logger
# @param self "Me, myself and Irene"
# @param msg logging string
def epanic( self, msg ):
try:
self.__log.getLogger(self).epanic( str(msg) )
except AttributeError:
print(msg)
##
# @class DCubeVersion
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)
# @brief DCube version holder
class DCubeVersion( object ):
__project = "DCube"
__version = "5.0"
__author = "Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)"
## str operator
# @param self "Me, myself and Irene"
def __str__( self ):
return "%s %s by %s" % ( self.__project, self.__version, self.__author )
## DCube version getter
# @param self "Me, myself and Irene"
def version( self ):
return str(self)
## python version getter
# @param self "Me, myself and Irene"
def python( self ):
return "using Python %s" % sys.version.replace("\n", "").strip("\n")
## root version getter
# @param self "Me, myself and Irene"
def root( self ):
out = "using ROOT "
try:
if ( "ROOT" not in dir() ):
import ROOT
out += ROOT.gROOT.GetVersion().strip("\n")
except:
out += "UNKNOWN"
return out
##
# @class DCubeException
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAgmail.com)
# @brief class for DCube triggered execution errors
class DCubeException( Exception ):
## c'tor
# @param self "Me, myself and Irene"
# @param value whatever, who cares, this is python, dumb!
def __init__( self, value ):
self.value = value
## exception printing
# @param self "Me, myself and Irene"
def __str__( self ):
return repr( self.value )
##
# @class test_DCubeUtils
# @author Krzysztof Daniel Ciba (Krzysztof.Ciba@NOSPAMgmail.com)
# @brief test case for DCubeUtils module classes
class test_DCubeUtils( unittest.TestCase ):
## test case setup
# @param self "Me, myself and Irene"
def setUp( self ):
self.logger = DCubeLogger( "test_DCubeUtils.log", logName="test_DCubeUtils", toConsole=True )
self.exception = DCubeException("test exception, don't panic")
self.version = DCubeVersion()
self.base = DCubeObject( self )
self.log = DCubeLogger.getLogger( self )
pass
## c'tors
# @param self "Me, myself and Irene"
def test_01_constructors( self ):
try:
self.exception = DCubeException("test exception, don't panic!")
self.version = DCubeVersion()
self.base = DCubeObject( self )
self.log = DCubeLogger.getLogger( self )
except:
pass
self.assertEqual( isinstance( self.exception, DCubeException), True )
self.assertEqual( isinstance( self.version, DCubeVersion), True )
self.assertEqual( isinstance( self.base, DCubeObject), True )
## DCubeLogger interface
# @param self "me, myself and Irene"
def test_02_logger( self ):
self.log.debug("debug level text")
self.log.info("info level text")
self.log.warn("warning level text")
self.log.error("error level text")
self.log.panic("fatal level text")
try:
raise NameError("intentional NameError, don't panic!")
except NameError as value:
self.log.epanic("exception level text")
self.log.toConsole(False)
self.log.info("this won't be printed to console")
self.log.toConsole(True)
self.log.info("this will be printed to console")
self.logger.setLevel("INFO")
self.log.debug("this should not be printed")
self.logger.setLevel("DEBUG")
self.log.debug("while this should be printed")
## DCubeException interface
# @param self "Me, myslf and Irene"
def test_03_exception( self ):
try:
raise self.exception
except DCubeException as value:
self.log.epanic(value)
## DCubeObject interface
# @param self "Me, myself and Irene"
def test_04_DCubeObject( self ):
self.base.debug("debug level text")
self.base.info("info level text")
self.base.warn("warn level text")
self.base.error("error level text")
self.base.panic("panic level text")
try:
raise NameError("intentional NameError, don't panic!")
except NameError:
self.base.epanic("exception level text")
## DCubeVersion interface
# @param self "Me, myself and Irene"
def test_05_DCubeVersion( self ):
self.log.info( self.version.version() )
self.log.info( self.version.root() )
self.log.info( self.version.python() )
self.log.info( self.version )
## test case execution
if __name__ == "__main__":
testLoader = unittest.TestLoader()
suite = testLoader.loadTestsFromTestCase(test_DCubeUtils)
unittest.TextTestRunner(verbosity=3).run(suite)
This diff is collapsed.
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#!/bin/env python
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
import sys, os
try: from DCubeApp import DCubeApp
except: from DCubeClient.DCubeApp import DCubeApp
if __name__ == "__main__":
## to run ROOT in batch mode
sys.argv.append("-b")
DCubeApp( )
This diff is collapsed.
#!/bin/csh
# enviroment setup for dcube.py running on lxplus for (t)csh shell
#
# Aug 16, 2007 - cibak - switch to root 5.16/00
# Oct 23, 2007 - cibak - switch to root 5.17/04
# Apr 10, 2008 - cibak - switch to root 5.19/02 and python 2.5
#
setenv ROOT_VER 5.19.02
setenv BIN slc4_amd64_gcc34
setenv ROOTSYS /afs/cern.ch/sw/lcg/external/root/${ROOT_VER}/${BIN}/root
setenv PYTHONPATH ${ROOTSYS}/lib:/afs/cern.ch/sw/lcg/external/Python/2.5/${BIN}/lib/python2.5
setenv PATH ${ROOTSYS}/bin:/afs/cern.ch/sw/lcg/external/Python/2.5/${BIN}/bin:${PATH}
setenv LD_LIBRARY_PATH ${ROOTSYS}/lib:/afs/cern.ch/sw/lcg/external/Python/2.5/${BIN}/lib
#!/bin/bash
#
# enviroment setup script for dcube.py running on lxplus for (ba,z)sh shell
#
# Aug 16, 2007 - cibak - switch to root 5.16/00
# Oct 23, 2007 - cibak - switch to root 5.17/04
# Apr 10, 2008 - cibak - switch to root 5.19/02 and python 2.5
#
export ROOT_VER=5.19.02
export BIN=slc4_amd64_gcc34
export ROOTSYS=/afs/cern.ch/sw/lcg/external/root/${ROOT_VER}/${BIN}/root
export PYTHONPATH=${ROOTSYS}/lib:/afs/cern.ch/sw/lcg/external/Python/2.5/${BIN}/lib/python2.5
export PATH=${ROOTSYS}/bin:/afs/cern.ch/sw/lcg/external/Python/2.5/${BIN}/bin:${PATH}
export LD_LIBRARY_PATH=${ROOTSYS}/lib:/afs/cern.ch/sw/lcg/external/Python/2.5/${BIN}/lib
#
# dummy job options
#
print "This is only placeholder, does nothing..."
# run one event and exit
theApp.EvtMax = 1
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment