diff --git a/TileCalorimeter/TileConditions/CMakeLists.txt b/TileCalorimeter/TileConditions/CMakeLists.txt index 56421c4e223d9cc42b4173c78a756e5d5443c848..cfad4ea2f1e72ac50346b0864f9fd3c98afb0132 100644 --- a/TileCalorimeter/TileConditions/CMakeLists.txt +++ b/TileCalorimeter/TileConditions/CMakeLists.txt @@ -99,3 +99,9 @@ if( NOT SIMULATIONBASE ) SCRIPT python -m TileConditions.TileConditionsConfig POST_EXEC_SCRIPT nopost.sh ) endif() + + +# Check python syntax: +atlas_add_test( flake8 + SCRIPT flake8 --select=F,E7,E9,W6 ${CMAKE_CURRENT_SOURCE_DIR}/python + POST_EXEC_SCRIPT nopost.sh ) diff --git a/TileCalorimeter/TileConditions/python/TileCondToolConf.py b/TileCalorimeter/TileConditions/python/TileCondToolConf.py index 326edff521265d1179d3e58621f3f8deaa67004a..606b65e5ace282b6adef6cbd9bde88146dbbe729 100644 --- a/TileCalorimeter/TileConditions/python/TileCondToolConf.py +++ b/TileCalorimeter/TileConditions/python/TileCondToolConf.py @@ -1,12 +1,11 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration #file: TileCondToolConf.py #author: nils.gollub@cern.ch import string -from TileConditions.TileCondProxyConf import * -from AthenaCommon.Constants import INFO +from TileConditions.TileCondProxyConf import getTileCondProxy #=== check Athena running mode from AthenaCommon.AthenaCommonFlags import athenaCommonFlags @@ -40,7 +39,9 @@ def bookTileCalibCondAlg(calibData, proxy): #____________________________________________________________________________ def getTileCondToolEmscale(source = 'FILE', name = 'TileCondToolEmscale', **kwargs): - if not source in validSources: raise(Exception("Invalid source: %s" % source)) + if source not in validSources: + raise(Exception("Invalid source: %s" % source)) + from TileConditions.TileConditionsConf import TileCondToolEmscale from AthenaCommon.AlgSequence import AthSequencer @@ -61,10 +62,13 @@ def getTileCondToolEmscale(source = 'FILE', name = 'TileCondToolEmscale', **kwar #=== Connect COOL TileCondProxies to the tool #==================================================== from AthenaCommon.GlobalFlags import globalflags - if (globalflags.DataSource() == 'data'): onlCacheUnit = "OnlineMegaElectronVolts" + if (globalflags.DataSource() == 'data'): + onlCacheUnit = "OnlineMegaElectronVolts" - if isOnline and isUsedDataBaseRun2: oflLasFibProxy = None - else: oflLasFibProxy = getTileCondProxy('COOL', 'Flt', 'oflLasFib', 'TileCondProxyCool_OflLasFib') + if isOnline and isUsedDataBaseRun2: + oflLasFibProxy = None + else: + oflLasFibProxy = getTileCondProxy('COOL', 'Flt', 'oflLasFib', 'TileCondProxyCool_OflLasFib') oflCisLinProxy = getTileCondProxy('COOL', 'Flt', 'oflCisFitLin', 'TileCondProxyCool_OflCisLin') oflCisNlnProxy = getTileCondProxy('COOL', 'Flt', 'oflCisFitNln', 'TileCondProxyCool_OflCisNln') @@ -123,7 +127,9 @@ def getTileCondToolEmscale(source = 'FILE', name = 'TileCondToolEmscale', **kwar #____________________________________________________________________________ def getTileExpertToolEmscale(source='FILE', name='TileExpertToolEmscale', **kwargs): - if not source in validSources: raise(Exception("Invalid source: %s"%source)) + if source not in validSources: + raise(Exception("Invalid source: %s"%source)) + from TileConditions.TileConditionsConf import TileExpertToolEmscale from AthenaCommon.AlgSequence import AthSequencer @@ -282,7 +288,9 @@ def getTileCondToolMuID(source = 'FILE', name = 'TileCondToolMuID', **kwargs): #____________________________________________________________________________ def getTileCondToolTiming(source = 'FILE', runType = 'PHY', online = False, name = 'TileCondToolTiming', **kwargs): - if not runType in validRunTypes: raise(Exception("Invalid run type %s"%runType)) + if runType not in validRunTypes: + raise(Exception("Invalid run type %s"%runType)) + from TileConditions.TileConditionsConf import TileCondToolTiming #do some check for global flag here: if source='' and flag set, adopt flag @@ -334,7 +342,9 @@ def getTileCondToolTiming(source = 'FILE', runType = 'PHY', online = False, name #____________________________________________________________________________ def getTileCondToolPulseShape(source = 'FILE', runType = 'PHY', name = 'TileCondToolPulseShape', **kwargs): - if not runType in validRunTypes: raise(Exception("Invalid run type %s"%runType)) + if runType not in validRunTypes: + raise(Exception("Invalid run type %s"%runType)) + from TileConditions.TileConditionsConf import TileCondToolPulseShape #do some check for global flag here: if source='' and flag set, adopt flag @@ -433,7 +443,9 @@ def getTileCondToolMuRcvPulseShape(source = 'FILE', name = 'TileCondToolMuRcvPul #____________________________________________________________________________ def getTileBadChanTool(source = 'FILE', name = 'TileBadChanTool', **kwargs): - if not source in validSources: raise(Exception("Invalid source: %s"%source)) + if source not in validSources: + raise(Exception("Invalid source: %s"%source)) + from TileConditions.TileConditionsConf import TileBadChanTool from AthenaCommon.AlgSequence import AthSequencer @@ -452,8 +464,11 @@ def getTileBadChanTool(source = 'FILE', name = 'TileBadChanTool', **kwargs): #==================================================== #=== Connect COOL TileCondProxies to the tool #==================================================== - if isOnline and isUsedDataBaseRun2: offlineBadChannelsProxy = None - else: offlineBadChannelsProxy = getTileCondProxy('COOL','Bch','oflStatAdc','TileCondProxyCool_OflBch') + if isOnline and isUsedDataBaseRun2: + offlineBadChannelsProxy = None + else: + offlineBadChannelsProxy = getTileCondProxy('COOL','Bch','oflStatAdc','TileCondProxyCool_OflBch') + onlineBadChannelsProxy = getTileCondProxy('COOL','Bch','onlStatAdc','TileCondProxyCool_OnlBch') else: #======================================================== @@ -487,8 +502,10 @@ def getTileCondToolNoiseSample(source = 'FILE', name = 'TileCondToolNoiseSample' tool = None sampleNoise = 'TileSampleNoise' - if isOnline or not isUsedDataBaseRun2: onlineSampleNoiseProxy = None - else: onlineSampleNoiseProxy = getTileCondProxy('COOL','Flt','onlNoiseAdc','TileCondProxyCool_OnlineNoiseSample') + if isOnline or not isUsedDataBaseRun2: + onlineSampleNoiseProxy = None + else: + onlineSampleNoiseProxy = getTileCondProxy('COOL','Flt','onlNoiseAdc','TileCondProxyCool_OnlineNoiseSample') onlineSampleNoise = 'TileOnlineSampleNoise' if onlineSampleNoiseProxy else '' @@ -504,7 +521,8 @@ def getTileCondToolNoiseSample(source = 'FILE', name = 'TileCondToolNoiseSample' sampleNoiseProxy = getTileCondProxy('FILE','Flt','TileDefault.ped','TileCondProxyFile_NoiseSample') bookTileCalibCondAlg(sampleNoise, sampleNoiseProxy) - if (onlineSampleNoiseProxy): bookTileCalibCondAlg(onlineSampleNoise, onlineSampleNoiseProxy) + if (onlineSampleNoiseProxy): + bookTileCalibCondAlg(onlineSampleNoise, onlineSampleNoiseProxy) tool = TileCondToolNoiseSample(name, TileSampleNoise = sampleNoise, @@ -604,7 +622,9 @@ def getTileCondToolNoiseRawChn(source = 'FILE', name = 'TileCondToolNoiseRawChn' #____________________________________________________________________________ def getTileCellNoiseTool(source = 'FILE', name = 'TileCellNoiseTool', **kwargs): - if not source in validSources: raise(Exception("Invalid source: %s"%source)) + if source not in validSources: + raise(Exception("Invalid source: %s"%source)) + from TileConditions.TileConditionsConf import TileCellNoiseTool #do some check for global flag here: if source='' and flag set, adopt flag @@ -623,8 +643,11 @@ def getTileCellNoiseTool(source = 'FILE', name = 'TileCellNoiseTool', **kwargs): #____________________________________________________________________________ def getTileCondToolOfcCool(source = 'FILE', runType = 'PHY', ofcType = 'OF2', name = 'TileCondToolOfcCool', **kwargs): - if not source in validSources : raise(Exception("Invalid source: %s" % source )) - if not runType in validRunTypes: raise(Exception("Invalid run type %s" % runType)) + if source not in validSources: + raise(Exception("Invalid source: %s" % source )) + + if runType not in validRunTypes: + raise(Exception("Invalid run type %s" % runType)) from TileConditions.TileConditionsConf import TileCondToolOfcCool @@ -639,7 +662,8 @@ def getTileCondToolOfcCool(source = 'FILE', runType = 'PHY', ofcType = 'OF2', na if source == 'COOL': # There are OFC for OF1 only in DB used in Run2 - if ofcType == 'OF1' and not (isUsedDataBaseRun2 or isMC): return None + if ofcType == 'OF1' and not (isUsedDataBaseRun2 or isMC): + return None from TileCoolMgr import GetTileOfcCoolSource, AddTileOfcCoolSource, tileCoolMgr @@ -677,13 +701,16 @@ def getTileCondToolOfcCool(source = 'FILE', runType = 'PHY', ofcType = 'OF2', na #____________________________________________________________________________ def getTileCondToolTMDB(source = 'FILE', runType = 'PHY', name = 'TileCondToolTMDB', **kwargs): - if not runType in validRunTypes: raise(Exception("Invalid run type %s" % runType)) + if runType not in validRunTypes: + raise(Exception("Invalid run type %s" % runType)) + from TileConditions.TileConditionsConf import TileCondToolTMDB #do some check for global flag here: if source='' and flag set, adopt flag tool = None - if not isUsedDataBaseRun2: return None + if not isUsedDataBaseRun2: + return None TMDBThreshold = 'TileTMDBThreshold' TMDBDelay = 'TileTMDBDelay' @@ -738,7 +765,9 @@ def getTileCondToolDspThreshold(source = 'FILE', name = 'TileCondToolDspThreshol #==================================================== #=== Connect COOL TileCondProxies to the tool #==================================================== - if not isUsedDataBaseRun2: return None + if not isUsedDataBaseRun2: + return None + dspThresholdProxy = getTileCondProxy('COOL', 'Flt', 'oflDspThreshold', 'TileCondProxyCool_DspThreshold') elif source == 'FILE': #======================================================== diff --git a/TileCalorimeter/TileConditions/python/TileConditionsConfig.py b/TileCalorimeter/TileConditions/python/TileConditionsConfig.py index ea1c03d195c2643a836a38a59b264b45f3691455..45e981925eed9f503465005bb5be08f8aaa76d24 100644 --- a/TileCalorimeter/TileConditions/python/TileConditionsConfig.py +++ b/TileCalorimeter/TileConditions/python/TileConditionsConfig.py @@ -130,7 +130,6 @@ if __name__ == "__main__": ConfigFlags.Input.Files = defaultTestFiles.RAW ConfigFlags.lock() - from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator acc = ComponentAccumulator() acc.merge( tileCondCfg(ConfigFlags) ) diff --git a/TileCalorimeter/TileConditions/python/TileCoolMgr.py b/TileCalorimeter/TileConditions/python/TileCoolMgr.py index ebd2c81d3ac66eaa3a5b38a189c412490894b807..e4481c96462fd2b2d7dca09d03607c177f572803 100644 --- a/TileCalorimeter/TileConditions/python/TileCoolMgr.py +++ b/TileCalorimeter/TileConditions/python/TileCoolMgr.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration #file: TileCoolMgr.py #author: nils.gollub@cern.ch @@ -15,6 +15,8 @@ tileCoolMgr = TileCoolMgr(isMC=(globalflags.DataSource()!='data'), isOnline=athenaCommonFlags.isOnline(), dbInstance=conddb.GetInstance()) +defConnStr = 'TILE' + def GetTileOfcCoolSource(ofcType, runType = 'PHY'): return 'Ofc' + string.capwords(ofcType,'/').replace('/','') + runType.lower().capitalize() diff --git a/TileCalorimeter/TileConditions/python/TileCoolMgrClass.py b/TileCalorimeter/TileConditions/python/TileCoolMgrClass.py index 62d0e448e343ab79fb8fa36efa968c98d532fcf5..8aa2e34fda331ae48919d705c555362279c8e198 100644 --- a/TileCalorimeter/TileConditions/python/TileCoolMgrClass.py +++ b/TileCalorimeter/TileConditions/python/TileCoolMgrClass.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration #file: TileCoolMgr.py #author: nils.gollub@cern.ch @@ -57,11 +57,14 @@ class TileCoolMgr: if not idInfo: self.__log.error("CondId \'%s\' not recognized!" % condId) return None - elif idInfo[5] != "": return idInfo[5] - elif len(self.getTag(condId)): return self.getTag(condId) + elif idInfo[5] != "": + return idInfo[5] + elif len(self.getTag(condId)): + return self.getTag(condId) else: folder = self.getActualFolder(condId) - if folder: return folder + if folder: + return folder else: self.__log.error("Cannot find out key for \'%s\'!" % condId) return None @@ -82,8 +85,10 @@ class TileCoolMgr: self.__log.error("CondId \'%s\' not recognized!" % condId) return None else: - if idInfo[4]=="SplitMC": return True - else: return False + if idInfo[4]=="SplitMC": + return True + else: + return False #_______________________________________________________________ def isSplitOnline(self, condId): @@ -92,8 +97,10 @@ class TileCoolMgr: self.__log.error("CondId \'%s\' not recognized!" % condId) return None else: - if idInfo[4]=="SplitOnline": return True - else: return False + if idInfo[4]=="SplitOnline": + return True + else: + return False #_______________________________________________________________ def isOfflineOnly(self, condId): @@ -102,8 +109,10 @@ class TileCoolMgr: self.__log.error("CondId \'%s\' not recognized!" % condId) return None else: - if idInfo[4]=="OfflineOnly": return True - else: return False + if idInfo[4]=="OfflineOnly": + return True + else: + return False #_______________________________________________________________ def isSqlite(self, condId): @@ -112,8 +121,10 @@ class TileCoolMgr: self.__log.error("CondId \'%s\' not recognized!" % condId) return None else: - if idInfo[4]=="Sqlite": return True - else: return False + if idInfo[4]=="Sqlite": + return True + else: + return False #_______________________________________________________________ @@ -203,15 +214,22 @@ class TileCoolMgr: def getActualFolder(self, condId): - if self.isOfflineOnly(condId): return self.getFolder(condId) - elif self.isSplitOnline(condId): - if self.isOnline() and not self.isMC(): return self.getFolder(condId) - else: return self.getFolderTwo(condId) + if self.isOfflineOnly(condId): + return self.getFolder(condId) + elif self.isSplitOnline(condId): + if self.isOnline() and not self.isMC(): + return self.getFolder(condId) + else: + return self.getFolderTwo(condId) elif self.isSplitMC(condId): - if self.isMC(): return self.getFolderTwo(condId) - else: return self.getFolder(condId) - elif self.isSqlite(condId): return self.getFolder(condId) - else: return None + if self.isMC(): + return self.getFolderTwo(condId) + else: + return self.getFolder(condId) + elif self.isSqlite(condId): + return self.getFolder(condId) + else: + return None @@ -348,7 +366,7 @@ class TileCoolMgr: -def TileCoolMgrConfig(configflags): +def TileCoolMgrConfig(configFlags): #Instantiate TileCoolMgr based on run3-style config flags return TileCoolMgr(isMC=configFlags.Input.isMC, isOnline=configFlags.common.isOnline, diff --git a/TileCalorimeter/TileConditions/python/TileInfoConfigurator.py b/TileCalorimeter/TileConditions/python/TileInfoConfigurator.py index e47d47a876116faa8f93e99dac6adb8979fc644f..b36ed0c7894d6c100029dcdb7eb67cf9b1ea0564 100644 --- a/TileCalorimeter/TileConditions/python/TileInfoConfigurator.py +++ b/TileCalorimeter/TileConditions/python/TileInfoConfigurator.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration ############################################################## # @@ -399,9 +399,12 @@ class _TileInfoConfigurator( TileInfoLoader ): self._msg.info("setting up DCS TileCal conditions data") dbConnStr = 'DCS_OFL' from IOVDbSvc.CondDB import conddb - if useHV: conddb.addFolder(dbConnStr, "/TILE/DCS/HV", className = 'CondAttrListCollection') - if useHVSET: conddb.addFolder(dbConnStr, "/TILE/DCS/HVSET", className = 'CondAttrListCollection') - if useSTATUS: conddb.addFolder(dbConnStr, "/TILE/DCS/STATES", className = 'CondAttrListCollection') + if useHV: + conddb.addFolder(dbConnStr, "/TILE/DCS/HV", className = 'CondAttrListCollection') + if useHVSET: + conddb.addFolder(dbConnStr, "/TILE/DCS/HVSET", className = 'CondAttrListCollection') + if useSTATUS: + conddb.addFolder(dbConnStr, "/TILE/DCS/STATES", className = 'CondAttrListCollection') from TileConditions.TileConditionsConf import TileDCSCondAlg condSequence += TileDCSCondAlg(name = dcsCondAlg, @@ -465,7 +468,7 @@ def TileInfoConfigurator(name="TileInfoLoader", **kwargs): #=== ensure the creation of service from AthenaCommon.AppMgr import theApp - if not svcName in theApp.CreateSvc: + if svcName not in theApp.CreateSvc: theApp.CreateSvc += [ svcName ] #=== ensure the availability of TileCablingSvc @@ -474,7 +477,6 @@ def TileInfoConfigurator(name="TileInfoLoader", **kwargs): svcMgr += CfgMgr.TileCablingSvc() #=== ensure the configuration of all needed tools - from AthenaCommon.AppMgr import ToolSvc # if not hasattr(ToolSvc, "TileBadChanTool"):