Skip to content
Snippets Groups Projects
Commit 943b72ba authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'py3.EventDisplaysOnline-20200402' into 'master'

EventDisplaysOnline: Python 3 fixes

See merge request !31699
parents af2b26a0 9bcb36ca
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,!31699EventDisplaysOnline: Python 3 fixes
# Copyright (C) 2002-2018 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 GetRunType():
"""Get the run type by reading the run-type setting in the partition from IS """
......@@ -25,7 +26,7 @@ def GetRunType():
runparams = ISObject(IPCPartition(partition), 'RunParams.RunParams','RunParams')
runparams.checkout()
runType = runparams.run_type
except UserWarning, err:
except UserWarning as err:
mlog.error(err)
#Set the default runtype
runType="collisions"
......@@ -69,7 +70,7 @@ def GetBFields():
#And calculate the flags
solenoidOn=((solenoidCurrent.value > 1000.) and (solenoidInvalid.value == 0))
toroidOn=((toroidCurrent.value > 1000.) and (toroidInvalid.value == 0))
except UserWarning, err:
except UserWarning as err:
mlog.error(err)
#Should always be able to access initial parititon
mlog.fatal("Failed to read magnetic field configuration from IS, aborting")
......@@ -85,6 +86,6 @@ def GetBFields():
if __name__ == "__main__":
runType=GetRunType()
print "RunType: %s"%runType
print ("RunType: %s"%runType)
bFields = GetBFields()
print "BFields (Sol,Tor):",bFields
print ("BFields (Sol,Tor):",bFields)
# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
import os, re, time
......@@ -15,8 +15,8 @@ def getEventlist(msg, directory):
# Event file, add tot the list
if matches:
run = "%012d" % long(matches.group(1))
event = "%012d" % long(matches.group(2))
run = "%012d" % int(matches.group(1))
event = "%012d" % int(matches.group(2))
fileentry = run, event, file
filelist.append(fileentry)
......@@ -30,7 +30,7 @@ def getEventlist(msg, directory):
msg.info("File '%s' does not belong in the output directory, removing it." % file)
try:
os.unlink("%s/%s" % (directory, file))
except OSError, err:
except OSError as err:
msg.warning("Could not remove '%s': %s" % (file, err))
except OSError:
# File was probably a temp file from another thread that already disappeared
......@@ -50,7 +50,7 @@ def getEventlist(msg, directory):
# msg.warning("One of the files is missing for run %s, event %s, removing the other as well." % (filelist[i][0], filelist[i][1]))
# try:
# os.unlink("%s/%s" % (directory, filelist[i][2]))
# except OSError, err:
# except OSError as err:
# msg.warning("Could not remove '%s': %s" % (filelist[i][2], err))
# Do not include such files in the list for atlas-live.cern.ch
......@@ -76,7 +76,7 @@ def pruneEvents(msg, directory, maxevents, eventlist):
try:
os.unlink("%s/%s" % (directory, atlantis))
os.unlink("%s/%s" % (directory, vp1))
except OSError, err:
except OSError as err:
msg.warning("Could not remove files for run %s, event %s: %s" % (run, event, err))
else:
......@@ -90,13 +90,13 @@ def writeEventlist(msg, directory, eventlist):
for run, event, atlantis, vp1 in eventlist:
file.write("run:%s,event:%s,atlantis:%s,vp1:%s\n" % (run, event, atlantis, vp1))
file.close()
except IOError, err:
except IOError as err:
msg.warning("Could not write event list: %s" % err)
# Rename for an atomic overwrite operation
try:
os.rename("%s/event.%d" % (directory, pid), "%s/event.list" % directory)
except OSError, err:
except OSError as err:
msg.warning("Could not rename event.%d to event.list: %s" % (pid, err))
# Perform all of these in one command
......
# Copyright (C) 2002-2018 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
__doc__ = """This service runs in the online Athena event display threads. It
manages the distribution of incoming events to the right event display streams.
......@@ -78,12 +80,12 @@ class OnlineEventDisplaysSvc( PyAthena.Svc ):
self.TrigDecMaker = PyAthena.py_alg('TrigDecMaker')
self.TrigDecTool = PyAthena.py_tool('Trig::TrigDecisionTool/TrigDecisionTool', iface='Trig::TrigDecisionTool')
self.msg.info("TrigDecTool: %s" % self.TrigDecTool)
except Exception, err:
except Exception as err:
self.msg.warning("Coult not retrieve TrigDecisionTool: %s" % err)
try:
eventInfo = PyEventTools.getEventInfo('')
except LookupError, err:
except LookupError as err:
self.msg.error("Could not retrieve EventInfo: %s" % err)
return StatusCode.Recoverable
......@@ -99,7 +101,7 @@ class OnlineEventDisplaysSvc( PyAthena.Svc ):
streamTags = triggerInfo.streamTags()
else:
streamTags = []
except Exception, err:
except Exception as err:
self.msg.error("Exception occured while reading event/trigger info: %s" % err)
return StatusCode.Recoverable
......@@ -129,7 +131,7 @@ class OnlineEventDisplaysSvc( PyAthena.Svc ):
# streams += ['MinBias']
#if self.TrigDecTool.isPassed('L1_MU0') or self.TrigDecTool.isPassed('L1_MU6') or self.TrigDecTool.isPassed('L1_MU10'):
# streams += ['Muons']
except Exception, err:
except Exception as err:
self.msg.error("Exception occured while using TrigDecTool: %s" % err)
try:
......@@ -137,19 +139,19 @@ class OnlineEventDisplaysSvc( PyAthena.Svc ):
if stream in self.public:
ready4physics = ISInfoAny()
self.dict.getValue('RunParams.Ready4Physics', ready4physics)
print "Ready for physics: %s " % ready4physics.get()
print ("Ready for physics: %s " % ready4physics.get())
runparams = ISObject(self.partition, 'RunParams.RunParams','RunParams')
runparams.checkout()
physicsReady = ISObject(self.partition, 'RunParams.Ready4Physics','Ready4PhysicsInfo')
physicsReady.checkout()
print "Ready for physics: %r" % (physicsReady.ready4physics)
print ("Ready for physics: %r" % (physicsReady.ready4physics))
#if ready4physics.get() and physicsReady.ready4physics and runparams.T0_project_tag in self.projecttags:
if physicsReady.ready4physics and runparams.T0_project_tag in self.projecttags:
streams += ['Public']
else:
self.msg.debug("RunParams.Ready4Physics is not set, run number is not set, or T0_project_tag is not set to any of %s" % ", ".join(self.projecttags))
break
except Exception, err:
except Exception as err:
self.msg.error("Exception occured while reading RunParams.Ready4Physics: %s" % err)
# Randomize list of streams
......@@ -177,7 +179,7 @@ class OnlineEventDisplaysSvc( PyAthena.Svc ):
os.chown(self.directory, -1, self.DQMgid)
self.msg.info("Created output directory \'%s\' for stream \'%s\'" % (self.directory, self.stream))
break
except OSError, err:
except OSError as err:
self.msg.warning("Failed to create output directory \'%s\' for stream \'%s\': %s", (self.directory, self.stream, err.strerror))
self.directory = ''
......@@ -196,7 +198,7 @@ class OnlineEventDisplaysSvc( PyAthena.Svc ):
# And also for the VP1 event producer algorithm
self.VP1EventProducer.getProperty('DestinationDirectory').setValue(self.directory)
except Exception, err:
except Exception as err:
self.msg.error("Exception occured while setting job options: %s" % err)
return StatusCode.Failure
......
......@@ -156,4 +156,4 @@ if rec.doHeavyIon:
### Finally, print setup if in debug mode
if AtlantisMsgLvl <= DEBUG:
print "\n\n\t Atlantis setup\n",AlgoJiveXML,"\n\n"
printfunc ("\n\n\t Atlantis setup\n",AlgoJiveXML,"\n\n")
......@@ -38,6 +38,6 @@ ByteStreamEmonCtrlSvc.OutputLevel=BSEmonMsgLvl
ISPropertySvc.OutputLevel=BSEmonMsgLvl
if BSEmonMsgLvl <= DEBUG:
print "\n\n\t ISPropertySvc setup:\n",ISPropertySvc,"\n\n"
print "\n\n\t ByteStreamEmonControl setup:\n",ByteStreamEmonCtrlSvc,"\n\n"
printfunc ("\n\n\t ISPropertySvc setup:\n",ISPropertySvc,"\n\n")
printfunc ("\n\n\t ByteStreamEmonControl setup:\n",ByteStreamEmonCtrlSvc,"\n\n")
......@@ -26,7 +26,7 @@ ByteStreamEmonInputSvc = svcMgr.ByteStreamInputSvc
# ############################################################
if not 'Partition' in dir():
Partition = 'ATLAS'
print "ByteStreamEmonInputSvc: Setting partition to : %s" % (Partition)
printfunc ("ByteStreamEmonInputSvc: Setting partition to : %s" % (Partition))
ByteStreamEmonInputSvc.Partition = Partition
# #########################################
......@@ -160,4 +160,4 @@ if not 'BSEmonMsgLvl' in dir():
ByteStreamEmonInputSvc.OutputLevel=BSEmonMsgLvl
if BSEmonMsgLvl <= DEBUG:
print "\n\n\t ByteStreamEmonInput setup:\n",ByteStreamEmonInputSvc,"\n\n"
printfunc ("\n\n\t ByteStreamEmonInput setup:\n",ByteStreamEmonInputSvc,"\n\n")
......@@ -111,7 +111,7 @@ if not len(jobId) == 5:
jobId = ['Athena-EventProcessor', 'Athena-EventDisplays-Segment', 'EventDisplays-Rack', 'tmp', '%d' % randint(0, 999)]
IPC_timeout = int(os.environ['TDAQ_IPC_TIMEOUT'])
print " IPC_timeout Envrionment Variable = %d" %IPC_timeout
printfunc (" IPC_timeout Envrionment Variable = %d" %IPC_timeout)
#################################################################################
#from random import randrange
......
......@@ -16,8 +16,8 @@ svcMgr += outputStreamSequencerSvc
from VP1AlgsEventProd.VP1AlgsEventProdConf import VP1EventProd
VP1EventProducer = VP1EventProd(InputPoolFile = StreamESD.OutputFile)
## =================== Added 09/03/15 by sjiggins =================
print "<<<<<<< VP1 Output File >>>>>>>"
print "OutputFile: %s" % StreamESD.OutputFile
printfunc ("<<<<<<< VP1 Output File >>>>>>>")
printfunc ("OutputFile: %s" % StreamESD.OutputFile)
## ================================================================
#Write out files in the directory given by the stream name
......@@ -37,4 +37,4 @@ topSequence += VP1EventProducer
### Finally print setup in debug mode
if VP1MsgLvl <= DEBUG:
print "\n\n\t VP1 setup\n",VP1EventProducer,"\n\n"
printfunc ("\n\n\t VP1 setup\n",VP1EventProducer,"\n\n")
......@@ -9,7 +9,7 @@ while not partitionUp:
runparams.checkout()
partitionUp=True
except Exception, e:
print "%s partition is not up, sleeping for 30 seconds" % partitionName
except Exception as e:
printfunc ("%s partition is not up, sleeping for 30 seconds" % partitionName)
time.sleep(30)
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