Skip to content
Snippets Groups Projects
Commit 1fbf0951 authored by scott snyder's avatar scott snyder
Browse files

VP1Algs: Python 3 / flake8 fixes

Updates for python 3 compatibility.
Enable flake8 checking and fix warnings.
parent 704a2ed4
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ atlas_add_component( VP1Algs ...@@ -29,7 +29,7 @@ atlas_add_component( VP1Algs
# Install files from the package: # Install files from the package:
atlas_install_headers( VP1Algs ) atlas_install_headers( VP1Algs )
atlas_install_python_modules( python/*.py ) atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
atlas_install_joboptions( share/*.py ) atlas_install_joboptions( share/*.py )
atlas_install_scripts( share/vp1 ) atlas_install_scripts( share/vp1 )
atlas_install_scripts( share/clear-bash-hash-table-vp1 ) atlas_install_scripts( share/clear-bash-hash-table-vp1 )
......
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from __future__ import print_function
def readFileSimplified(filename): def readFileSimplified(filename):
import os.path import os.path
...@@ -16,12 +17,12 @@ def filterEntry(parts): ...@@ -16,12 +17,12 @@ def filterEntry(parts):
assert len(parts) in [1,2] assert len(parts) in [1,2]
filter_run = int(parts[0]) if len(parts)==2 else None filter_run = int(parts[0]) if len(parts)==2 else None
filter_evt = int(parts[1]) if len(parts)==2 else int(parts[0]) filter_evt = int(parts[1]) if len(parts)==2 else int(parts[0])
assert (filter_run==None or filter_run>=0) and filter_evt>=0 assert (filter_run is None or filter_run>=0) and filter_evt>=0
return (filter_run,filter_evt) return (filter_run,filter_evt)
def readFiltersFromFile(filename): def readFiltersFromFile(filename):
lines = readFileSimplified(filename) lines = readFileSimplified(filename)
if lines==None: return None if lines is None: return None
filts=[] filts=[]
for l in lines: for l in lines:
filts+=[filterEntry(l.replace(':',' ').split())] filts+=[filterEntry(l.replace(':',' ').split())]
...@@ -43,18 +44,18 @@ def parseFilterString(s): ...@@ -43,18 +44,18 @@ def parseFilterString(s):
filters += [filefilt] filters += [filefilt]
continue continue
filters += [filterEntry(filt.split(':'))] filters += [filterEntry(filt.split(':'))]
except: except Exception:
filters=[] filters=[]
def vp1CfgErr(s): print "VP1 CONFIGURATION ERROR: %s" % s#fixme: should go in common utils module def vp1CfgErr(s): print ("VP1 CONFIGURATION ERROR: %s" % s)#fixme: should go in common utils module
vp1CfgErr("Badly formatted filter string '%s'" % str(s)) vp1CfgErr("Badly formatted filter string '%s'" % str(s))
raise raise
return (excludemode,filters) return (excludemode,filters)
def installEventFilter(filters): def installEventFilter(filters):
def vp1filter(run,evt): def vp1filter(run,evt):
print "vp1filter(%i,%i) called" %(run,evt) print ("vp1filter(%i,%i) called" %(run,evt))
for filter in filters[1]: for filter in filters[1]:
if evt==filter[1] and (filter[0]==None or filter[0]==run): return not filters[0] if evt==filter[1] and (filter[0] is None or filter[0]==run): return not filters[0]
return filters[0] return filters[0]
from AthenaCommon.AlgSequence import AthSequencer from AthenaCommon.AlgSequence import AthSequencer
seq = AthSequencer('AthMasterSeq') seq = AthSequencer('AthMasterSeq')
......
...@@ -38,7 +38,7 @@ if not 'vp1Trig' in dir(): vp1Trig=False ...@@ -38,7 +38,7 @@ if not 'vp1Trig' in dir(): vp1Trig=False
if not 'vp1NSWAGDDFiles' in dir(): vp1NSWAGDDFiles=[] if not 'vp1NSWAGDDFiles' in dir(): vp1NSWAGDDFiles=[]
if not 'vp1MuonLayout' in dir(): vp1MuonLayout="" if not 'vp1MuonLayout' in dir(): vp1MuonLayout=""
def vp1CfgErr(s): print "VP1 CONFIGURATION ERROR: %s" % s def vp1CfgErr(s): printfunc ("VP1 CONFIGURATION ERROR: %s" % s)
if (vp1Fatras and not vp1ID): if (vp1Fatras and not vp1ID):
vp1CfgErr("Fatras can not be enabled without inner detector. Turning off Fatras.") vp1CfgErr("Fatras can not be enabled without inner detector. Turning off Fatras.")
...@@ -59,8 +59,8 @@ if ( vp1FatrasTruthKey != "" and not vp1Fatras ): ...@@ -59,8 +59,8 @@ if ( vp1FatrasTruthKey != "" and not vp1Fatras ):
vp1CfgErr("FatrasTruthKey set but Fatras not enabled. Unsetting FatrasTruthKey.") vp1CfgErr("FatrasTruthKey set but Fatras not enabled. Unsetting FatrasTruthKey.")
vp1FatrasTruthKey="" vp1FatrasTruthKey=""
print "*** VP1 NOTE *** setting COIN_GLXGLUE env vars to make screenshots working remotely..." printfunc ("*** VP1 NOTE *** setting COIN_GLXGLUE env vars to make screenshots working remotely...")
print "*** VP1 NOTE *** COIN_GLXGLUE_NO_GLX13_PBUFFERS=1 - " + "COIN_GLXGLUE_NO_PBUFFERS=1" printfunc ("*** VP1 NOTE *** COIN_GLXGLUE_NO_GLX13_PBUFFERS=1 - " + "COIN_GLXGLUE_NO_PBUFFERS=1")
os.putenv("COIN_GLXGLUE_NO_GLX13_PBUFFERS","1") os.putenv("COIN_GLXGLUE_NO_GLX13_PBUFFERS","1")
os.putenv("COIN_GLXGLUE_NO_PBUFFERS","1") os.putenv("COIN_GLXGLUE_NO_PBUFFERS","1")
...@@ -263,7 +263,7 @@ from AtlasGeoModel import GeoModelInit ...@@ -263,7 +263,7 @@ from AtlasGeoModel import GeoModelInit
from AthenaCommon.AppMgr import ToolSvc from AthenaCommon.AppMgr import ToolSvc
if vp1Muon and len(vp1NSWAGDDFiles)>0: if vp1Muon and len(vp1NSWAGDDFiles)>0:
print "*** VP1 NOTE *** You specified custom vp1NSWAGDDFiles, creating NSWAGDDTool to read NSWAGDD information from custom file(s) instead from built-in geometry" printfunc ("*** VP1 NOTE *** You specified custom vp1NSWAGDDFiles, creating NSWAGDDTool to read NSWAGDD information from custom file(s) instead from built-in geometry")
from AthenaCommon.AppMgr import theApp from AthenaCommon.AppMgr import theApp
from AGDD2GeoSvc.AGDD2GeoSvcConf import AGDDtoGeoSvc from AGDD2GeoSvc.AGDD2GeoSvcConf import AGDDtoGeoSvc
AGDD2Geo = AGDDtoGeoSvc() AGDD2Geo = AGDDtoGeoSvc()
...@@ -274,7 +274,7 @@ if vp1Muon and len(vp1NSWAGDDFiles)>0: ...@@ -274,7 +274,7 @@ if vp1Muon and len(vp1NSWAGDDFiles)>0:
NSWAGDDTool = CfgMgr.NSWAGDDTool("NewSmallWheel", DefaultDetector="Muon", ReadAGDD=False, XMLFiles=vp1NSWAGDDFiles, Volumes=["NewSmallWheel"]) NSWAGDDTool = CfgMgr.NSWAGDDTool("NewSmallWheel", DefaultDetector="Muon", ReadAGDD=False, XMLFiles=vp1NSWAGDDFiles, Volumes=["NewSmallWheel"])
AGDD2Geo.Builders += [ NSWAGDDTool ] AGDD2Geo.Builders += [ NSWAGDDTool ]
if vp1Muon and vp1MuonLayout!="": if vp1Muon and vp1MuonLayout!="":
print "*** VP1 NOTE *** You specified custom vp1MuonLayout, using %s as muon geometry"%vp1MuonLayout printfunc ("*** VP1 NOTE *** You specified custom vp1MuonLayout, using %s as muon geometry"%vp1MuonLayout)
from GeoModelSvc.GeoModelSvcConf import GeoModelSvc from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
GeoModelSvc = GeoModelSvc() GeoModelSvc = GeoModelSvc()
GeoModelSvc.MuonVersionOverride=vp1MuonLayout GeoModelSvc.MuonVersionOverride=vp1MuonLayout
...@@ -456,8 +456,8 @@ if vp1Extrapolator and (vp1ID or vp1Muon): ...@@ -456,8 +456,8 @@ if vp1Extrapolator and (vp1ID or vp1Muon):
# ToolMuonDriftCircle = MdtTubeHitOnTrackCreator , # ToolMuonDriftCircle = MdtTubeHitOnTrackCreator ,
# Mode = 'all') # Mode = 'all')
# ToolSvc += VP1RotCreator # ToolSvc += VP1RotCreator
# print VP1RotCreator # printfunc (VP1RotCreator)
# print MdtTubeHitOnTrackCreator # printfunc (MdtTubeHitOnTrackCreator)
# #
# from TrkKalmanFitter.TrkKalmanFitterConf import Trk__KalmanFitter as ConfiguredKalmanFitter # from TrkKalmanFitter.TrkKalmanFitterConf import Trk__KalmanFitter as ConfiguredKalmanFitter
# VP1KalmanFitter = ConfiguredKalmanFitter(name = 'VP1KalmanFitter', # VP1KalmanFitter = ConfiguredKalmanFitter(name = 'VP1KalmanFitter',
...@@ -472,7 +472,7 @@ if vp1Extrapolator and (vp1ID or vp1Muon): ...@@ -472,7 +472,7 @@ if vp1Extrapolator and (vp1ID or vp1Muon):
# #
# ToolSvc += VP1KalmanFitter # ToolSvc += VP1KalmanFitter
# #
# print VP1KalmanFitter # printfunc (VP1KalmanFitter)
# os.putenv("VP1_JOBCFG_EXTRA_VP1_FITTERS",VP1KalmanFitter.name()) # os.putenv("VP1_JOBCFG_EXTRA_VP1_FITTERS",VP1KalmanFitter.name())
# #
# #
...@@ -502,7 +502,7 @@ if vp1Extrapolator and (vp1ID or vp1Muon): ...@@ -502,7 +502,7 @@ if vp1Extrapolator and (vp1ID or vp1Muon):
# SignedDriftRadius = True, # SignedDriftRadius = True,
# RecalculateDerivatives= True # RecalculateDerivatives= True
# ) # )
# print VP1GlobalChi2Fitter # printfunc (VP1GlobalChi2Fitter)
# ToolSvc += VP1GlobalChi2Fitter # ToolSvc += VP1GlobalChi2Fitter
# #
# VP1GlobalChi2Fitter.OutputLevel=DEBUG # VP1GlobalChi2Fitter.OutputLevel=DEBUG
......
...@@ -17,4 +17,4 @@ if not 'VP1ATLREL' in dir(): ...@@ -17,4 +17,4 @@ if not 'VP1ATLREL' in dir():
if versionMinor>99: versionMinor=99 if versionMinor>99: versionMinor=99
if versionMinor==99 or versionPatch>99: versionPatch=99 if versionMinor==99 or versionPatch>99: versionPatch=99
VP1ATLREL=10000*versionMajor+100*versionMinor+versionPatch VP1ATLREL=10000*versionMajor+100*versionMinor+versionPatch
print "VP1ATLREL: "+str(VP1ATLREL) printfunc ("VP1ATLREL: "+str(VP1ATLREL))
...@@ -4,42 +4,42 @@ import os ...@@ -4,42 +4,42 @@ import os
if globalflags.DataSource() == 'data' and os.getenv("FRONTIER_SERVER") == None : if globalflags.DataSource() == 'data' and os.getenv("FRONTIER_SERVER") == None :
# Patch dblookup.xml to avoid any attempt to use sqlite replicas # Patch dblookup.xml to avoid any attempt to use sqlite replicas
print "VP1 Info: real data mode and Frontier environment not set - need to patch dblookup.xml to avoid using local sqlite replicas." printfunc ("VP1 Info: real data mode and Frontier environment not set - need to patch dblookup.xml to avoid using local sqlite replicas.")
if os.path.exists("dblookup.xml"): if os.path.exists("dblookup.xml"):
print "VP1 Warning: dblookup.xml already found in run directory. Will not attempt to created patched copy." printfunc ("VP1 Warning: dblookup.xml already found in run directory. Will not attempt to created patched copy.")
os.putenv("CORAL_DBLOOKUP_PATH",".") os.putenv("CORAL_DBLOOKUP_PATH",".")
else: else:
if os.getenv("CORAL_AUTH_PATH") == None or not os.path.isdir(os.getenv("CORAL_AUTH_PATH")): if os.getenv("CORAL_AUTH_PATH") == None or not os.path.isdir(os.getenv("CORAL_AUTH_PATH")):
print "VP1 Warning: CORAL_AUTH_PATH is not set or does not point to directory. Can't create patched dblookup.xml." printfunc ("VP1 Warning: CORAL_AUTH_PATH is not set or does not point to directory. Can't create patched dblookup.xml.")
else: else:
dblookupFileLocation=os.getenv("CORAL_AUTH_PATH")+"/dblookup.xml" dblookupFileLocation=os.getenv("CORAL_AUTH_PATH")+"/dblookup.xml"
if not os.path.exists(dblookupFileLocation) or not os.path.isfile(dblookupFileLocation): if not os.path.exists(dblookupFileLocation) or not os.path.isfile(dblookupFileLocation):
print "VP1 Warning: Did not find CORAL_AUTH_PATH/dblookup.xml. Can't create patched dblookup.xml." printfunc ("VP1 Warning: Did not find CORAL_AUTH_PATH/dblookup.xml. Can't create patched dblookup.xml.")
else: else:
print "VP1 Warning: Attempting to create patched dblookup.xml in current directory" printfunc ("VP1 Warning: Attempting to create patched dblookup.xml in current directory")
os.system("cat $CORAL_AUTH_PATH/dblookup.xml |grep -v 'ALLP200.db'> dblookup.xml") os.system("cat $CORAL_AUTH_PATH/dblookup.xml |grep -v 'ALLP200.db'> dblookup.xml")
os.putenv("CORAL_DBLOOKUP_PATH",".") os.putenv("CORAL_DBLOOKUP_PATH",".")
if os.getenv("ATLAS_CONDDB")==None and (os.getenv("HOSTNAME") == None or os.getenv("HOSTNAME").find('.')<=0): if os.getenv("ATLAS_CONDDB")==None and (os.getenv("HOSTNAME") == None or os.getenv("HOSTNAME").find('.')<=0):
print "VP1 Warning: Unable to determine domain from runtime environment. Disabling attempt to find nearest replica." printfunc ("VP1 Warning: Unable to determine domain from runtime environment. Disabling attempt to find nearest replica.")
PoolSvc = Service( "PoolSvc" ) PoolSvc = Service( "PoolSvc" )
PoolSvc.SortReplicas = False PoolSvc.SortReplicas = False
print "" printfunc ("")
print " ==========>" printfunc (" ==========>")
print " ========>" printfunc (" ========>")
print " ======>" printfunc (" ======>")
print " ====>" printfunc (" ====>")
print " ====> VP1 Warning: Can't find nearest Oracle replica and you are running on real data." printfunc (" ====> VP1 Warning: Can't find nearest Oracle replica and you are running on real data.")
print " ====> Thus conditions data will have to come from the default, CERN (or you might crash!)." printfunc (" ====> Thus conditions data will have to come from the default, CERN (or you might crash!).")
print " ====>" printfunc (" ====>")
print " ====> Notice that this might SIGNIFICANTLY slow down (or even time-out) your job depending" printfunc (" ====> Notice that this might SIGNIFICANTLY slow down (or even time-out) your job depending")
print " ====> on your location and connection! You can avoid the issue (and this warning) by fixing" printfunc (" ====> on your location and connection! You can avoid the issue (and this warning) by fixing")
print " ====> your environment: either ATLAS_CONDDB or HOSTNAME. Alternatively you can edit a dblookup.xml file in your2" printfunc (" ====> your environment: either ATLAS_CONDDB or HOSTNAME. Alternatively you can edit a dblookup.xml file in your")
print " ====> directory to only leave in references to a closer replica in sections where such a replica is available." printfunc (" ====> directory to only leave in references to a closer replica in sections where such a replica is available.")
print " ====>" printfunc (" ====>")
print " ======>" printfunc (" ======>")
print " ========>" printfunc (" ========>")
print " ==========>" printfunc (" ==========>")
print "" printfunc ("")
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