From eb04b54bfd131d05c6e2dc6112a8818b88e4fe1d Mon Sep 17 00:00:00 2001 From: Nicolas Koehler <nicolas.koehler@cern.ch> Date: Fri, 4 Oct 2019 06:55:08 +0000 Subject: [PATCH] Use logger instead of print in AtlasGeoModel --- .../python/AtlasGeoDBInterface.py | 14 ++++----- .../python/CommonGMJobProperties.py | 16 +++++----- .../AtlasGeoModel/python/GeoModelConfig.py | 4 +-- .../python/InDetGMJobProperties.py | 29 ++++++++++--------- .../python/LArGMJobProperties.py | 27 ++++++++--------- .../GeoModel/AtlasGeoModel/python/MuonGM.py | 3 +- .../python/MuonGMJobProperties.py | 11 +++---- .../python/SetGeometryVersion.py | 3 +- 8 files changed, 55 insertions(+), 52 deletions(-) diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/AtlasGeoDBInterface.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/AtlasGeoDBInterface.py index f03c744cb80..660ca90357e 100755 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/AtlasGeoDBInterface.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/AtlasGeoDBInterface.py @@ -1,7 +1,6 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from __future__ import print_function - +from AthenaCommon import Logging import coral import os @@ -24,7 +23,7 @@ class AtlasGeoDBInterface: def __del__(self): - if self.bVerbose: print ("-> close DB connection") + Logging.log.verbose("-> close DB connection") del self.dbSession @@ -74,7 +73,7 @@ class AtlasGeoDBInterface: for currentRow in iter(query.execute()): for i in range(0,currentRow.size()): if currentRow[i].specification().name()=="TAG_ID": - if self.bVerbose: print ("*** GeoTagId ******** ",str(currentRow)) + Logging.log.verbose("*** GeoTagId ******** ",str(currentRow)) self.dbGeoTagId=currentRow[i].data() continue @@ -127,9 +126,8 @@ class AtlasGeoDBInterface: # Check if the geometry tag was found in the DB if self.dbGeoTagId=="": - print ("The geometry tag ",self.dbGeoTag," could not be found in the database.") - print ("Its name might be misspelled and/or the script might access a local DB that is not up to date.") - print ("") + Logging.log.error("The geometry tag ",self.dbGeoTag," could not be found in the database.") + Logging.log.error("Its name might be misspelled and/or the script might access a local DB that is not up to date.") import sys sys.exit(); @@ -151,7 +149,7 @@ class AtlasGeoDBInterface: bindstag2node = coral.AttributeList() condString="C.NODE_ID=A.NODE_ID AND A.TAG_ID=B.CHILD_TAG and B.PARENT_TAG IN (%s)" % str(tagIdList)[1:-1] - if self.bVerbose: print ("----------------------------\n"+condString) + Logging.log.verbose("----------------------------\n"+condString) query0.setCondition(condString,bindstag2node) # Analyze the output and collect the new tag and node versions diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/CommonGMJobProperties.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/CommonGMJobProperties.py index 170d7acf78d..c3f4edf0628 100644 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/CommonGMJobProperties.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/CommonGMJobProperties.py @@ -6,7 +6,7 @@ from AthenaCommon.GlobalFlags import globalflags from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties - +from AthenaCommon import Logging from AtlasGeoDBInterface import AtlasGeoDBInterface class CommonGMFlags: @@ -62,11 +62,11 @@ class CommonGMFlags: def dump(self): - print "Geometry tag CommonGMFlags : ",self.__dict__["geomTag"]," ------------------------------------" + Logging.log.info("Geometry tag CommonGMFlags : "+self.__dict__["geomTag"]+" ------------------------------------") - print "RUN flag : ",self.__dict__["Run"] - print "GeoType flag : ",self.__dict__["GeoType"] - print "Strip GeoType flag : ",self.__dict__["StripGeoType"] + Logging.log.info("RUN flag : "+self.__dict__["Run"]) + Logging.log.info("GeoType flag : "+self.__dict__["GeoType"]) + Logging.log.info("Strip GeoType flag : "+self.__dict__["StripGeoType"]) # ------------------------------------------------------------------------------------------------------------------ @@ -118,9 +118,9 @@ class CommonGeometryFlags_JobProperties(JobPropertyContainer): def dump(self): - print "RUN flag :", self.Run() - print "GeoType flag : ", self.GeoType() - print "Strip geoType flag : ", self.StripGeoType() + Logging.log.info("RUN flag :"+self.Run()) + Logging.log.info("GeoType flag : "+self.GeoType()) + Logging.log.info("Strip geoType flag : "+self.StripGeoType()) jobproperties.add_Container(CommonGeometryFlags_JobProperties) diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py index 1ce545eec3b..aab559dfe2c 100644 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py @@ -1,8 +1,8 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from __future__ import print_function from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaCommon.Configurable import Configurable +from AthenaCommon import Logging def GeoModelCfg(configFlags): version=configFlags.GeoModel.AtlasVersion @@ -47,4 +47,4 @@ if __name__ == "__main__": acc = GeoModelCfg( ConfigFlags ) acc.store( file( "test.pkl", "w" ) ) - print("All OK") + Logging.log.info("All OK") diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/InDetGMJobProperties.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/InDetGMJobProperties.py index ef96092a06f..43c5b63cf21 100755 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/InDetGMJobProperties.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/InDetGMJobProperties.py @@ -5,6 +5,7 @@ # from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AtlasGeoModel.CommonGMJobProperties import CommonGMFlags, CommonGeometryFlags +from AthenaCommon import Logging # ------------------------------------------------------------------------------------- # InDet geometry flags initialization @@ -76,14 +77,14 @@ class InDetGMFlags(CommonGMFlags, object): def dump(self): - print "Geometry tag InDetGMFlags : ",self.__dict__["geomTag"]," ------------------------------------" - print "VersionName = ",self.__dict__["VersionName"] - print "Layout = ",self.__dict__["Layout"] - print "DBM = ",self.__dict__["DBM"] + Logging.log.info("Geometry tag InDetGMFlags : "+self.__dict__["geomTag"]+" ------------------------------------") + Logging.log.info("VersionName = "+self.__dict__["VersionName"]) + Logging.log.info("Layout = "+self.__dict__["Layout"]) + Logging.log.info("DBM = "+self.__dict__["DBM"]) - print "SLHC flag : ",self.__dict__["SLHC"] - print "IBL flag : ",self.__dict__["IBL"] - print "IBL layout : ", self.__dict__["IBLlayout"] + Logging.log.info("SLHC flag : "+self.__dict__["SLHC"]) + Logging.log.info("IBL flag : "+self.__dict__["IBL"]) + Logging.log.info("IBL layout : "+ self.__dict__["IBLlayout"]) # ------------------------------------------------------------------------------------- @@ -168,14 +169,14 @@ class InDetGeometryFlags_JobProperties(JobPropertyContainer): def dump(self): - print "VersionName = ", self.GeoVersionName() - print "Layout = ", self.GeoLayout() - print "DBM = ", self.isDBM() + Logging.log.info("VersionName = "+self.GeoVersionName()) + Logging.log.info("Layout = "+self.GeoLayout()) + Logging.log.info("DBM = "+self.isDBM()) - print "SLHC flag : ", self.isSLHC() - print "IBL flag : ", self.isIBL() - print "IBL layout : ", self.IBLLayout() - print "Dynamic alignment : ", self.useDynamicAlignFolders() + Logging.log.info("SLHC flag : "+self.isSLHC()) + Logging.log.info("IBL flag : "+self.isIBL()) + Logging.log.info("IBL layout : "+self.IBLLayout()) + Logging.log.info("Dynamic alignment : "+self.useDynamicAlignFolders()) jobproperties.add_Container(InDetGeometryFlags_JobProperties) diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMJobProperties.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMJobProperties.py index 43bdf6499ee..b7ec52a70b2 100755 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMJobProperties.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMJobProperties.py @@ -5,6 +5,7 @@ # from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AtlasGeoModel.CommonGMJobProperties import CommonGMFlags +from AthenaCommon import Logging # ------------------------------------------------------------------------------------- # LAr geometry flags initialization @@ -48,13 +49,13 @@ class LArGMFlags(CommonGMFlags, object): def dump(self): - print "Geometry tag LArGMFlags : ",self.__dict__["geomTag"]," ------------------------------------" - print "Sagging = ",self.__dict__["Sagging"] - print "BarrelOn = ",self.__dict__["BarrelOn"] - print "EndcapON = ",self.__dict__["EndcapOn"] - print "Detailed Absorber = ",self.__dict__["DetAbs"] - print "Detailed Absorber EC = ",self.__dict__["DetAbs_EC"] - print "FCal geotype = ",self.__dict__["FCal_GeoType"] + Logging.log.info("Geometry tag LArGMFlags : "+self.__dict__["geomTag"]+" ------------------------------------") + Logging.log.info("Sagging = "+self.__dict__["Sagging"]) + Logging.log.info("BarrelOn = "+self.__dict__["BarrelOn"]) + Logging.log.info("EndcapON = "+self.__dict__["EndcapOn"]) + Logging.log.info("Detailed Absorber = "+self.__dict__["DetAbs"]) + Logging.log.info("Detailed Absorber EC = "+self.__dict__["DetAbs_EC"]) + Logging.log.info("FCal geotype = "+self.__dict__["FCal_GeoType"]) @@ -130,13 +131,13 @@ class LArGeometryFlags_JobProperties(JobPropertyContainer): def dump(self): - print "Sagging = ", self.Sagging() - print "Barrel_On = ", self.BarrelOn() - print "Endcap_On = ", self.EndcapOn() - print "Detailed absorber = ", self.DetailedAbsorber() - print "Detailed absorber EC = ", self.DetailedAbsorber_EC() + Logging.log.info("Sagging = "+self.Sagging()) + Logging.log.info("Barrel_On = "+self.BarrelOn()) + Logging.log.info("Endcap_On = "+self.EndcapOn()) + Logging.log.info("Detailed absorber = "+self.DetailedAbsorber()) + Logging.log.info("Detailed absorber EC = "+self.DetailedAbsorber_EC()) - print "FCal GeoType = ", self.FCalGeoType() + Logging.log.info("FCal GeoType = "+self.FCalGeoType()) jobproperties.add_Container(LArGeometryFlags_JobProperties) diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGM.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGM.py index f0c58ddd7e3..865348518c6 100755 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGM.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGM.py @@ -4,9 +4,10 @@ from AthenaCommon.JobProperties import jobproperties from AthenaCommon.DetFlags import DetFlags from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags from AtlasGeoModel.MuonGMJobProperties import MuonGeometryFlags +from AthenaCommon import Logging if ( jobproperties.Global.DetGeo() == "ctbh8" or jobproperties.Global.DetGeo() == "ctbh6" ): - print " CTB layout for Muon Spectrometer is not supported anymore" + Logging.log.warning(" CTB layout for Muon Spectrometer is not supported anymore") elif ( DetFlags.detdescr.Muon_on() ): from GeoModelSvc.GeoModelSvcConf import GeoModelSvc diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGMJobProperties.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGMJobProperties.py index 2ca7e13f32b..a8845a41d35 100755 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGMJobProperties.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/MuonGMJobProperties.py @@ -2,6 +2,7 @@ from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties from AtlasGeoModel.CommonGMJobProperties import CommonGMFlags, CommonGeometryFlags +from AthenaCommon import Logging # ------------------------------------------------------------------------------------- # Muon geometry flags initialization @@ -25,9 +26,9 @@ class MuonGMFlags(CommonGMFlags, object): else: self.__dict__["HasCSC"] = True def dump(self): - print "MuonGMFlags:" - print "Layout = ",self.__dict__["Layout"] - print "HasCSC = ",self.__dict__["HasCSC"] + Logging.log.info("MuonGMFlags:") + Logging.log.info("Layout = "+self.__dict__["Layout"]) + Logging.log.info("HasCSC = "+self.__dict__["HasCSC"]) class GeoLayout(JobProperty): @@ -59,8 +60,8 @@ class MuonGeometryFlags_JobProperties(JobPropertyContainer): self.hasCSC.unlock() def dump(self): - print "Layout = ", self.GeoLayout() - print "HasCSC = ", self.hasCSC() + Logging.log.info("Layout = "+self.GeoLayout()) + Logging.log.info("HasCSC = "+self.hasCSC()) jobproperties.add_Container(MuonGeometryFlags_JobProperties) diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/SetGeometryVersion.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/SetGeometryVersion.py index 4197881b70b..3e282c80f53 100755 --- a/DetectorDescription/GeoModel/AtlasGeoModel/python/SetGeometryVersion.py +++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/SetGeometryVersion.py @@ -2,6 +2,7 @@ from AthenaCommon.JobProperties import jobproperties from AthenaCommon.DetFlags import DetFlags +from AthenaCommon import Logging DDversion = jobproperties.Global.DetDescrVersion() @@ -55,5 +56,5 @@ relversion = rel_metadata['release'].split('.') if len(relversion) < 3: relversion = rel_metadata['base release'].split('.') -print "SetGeometryVersion.py obtained major release version %s" % relversion[0] +Logging.log.info("SetGeometryVersion.py obtained major release version %s" % relversion[0]) GeoModelSvc.SupportedGeometry = int(relversion[0]) -- GitLab