Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print function migration for RecoVertex_BeamSpotProducer #23872

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
93 changes: 47 additions & 46 deletions RecoVertex/BeamSpotProducer/scripts/BeamSpotWorkflow.py

Large diffs are not rendered by default.

103 changes: 52 additions & 51 deletions RecoVertex/BeamSpotProducer/scripts/CommonMethods.py

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions RecoVertex/BeamSpotProducer/scripts/beamvalidation.py
Expand Up @@ -25,6 +25,7 @@
Fermilab 2010

"""
from __future__ import print_function


import os, string, re, sys, math
Expand Down Expand Up @@ -185,9 +186,9 @@ def write_iovs(iovs, lines):
def get_listoftags(dest, auth,):

queryTags_cmd = "cmscond_list_iov -c "+dest+" -P "+auth+" -a | grep BeamSpotObjects"
print queryTags_cmd
print(queryTags_cmd)
outcmd = commands.getstatusoutput( queryTags_cmd )
print outcmd[1]
print(outcmd[1])

listtags = outcmd[1].split()

Expand Down Expand Up @@ -239,7 +240,7 @@ def get_lastIOVs( listoftags, dest, auth ):
lasttag = listoftags[itag][1]

queryIOVs_cmd = "cmscond_list_iov -c "+dest+" -P "+auth+" -t "+ lasttag
print queryIOVs_cmd
print(queryIOVs_cmd)

outcmd = commands.getstatusoutput( queryIOVs_cmd )

Expand Down Expand Up @@ -301,15 +302,15 @@ def get_plots(path,output, iovs, tag):

initial = str(int(initial) -100 )
cmd = path+"/plotBeamSpotDB.py -b -P -t "+tag+" -i "+initial +" -f "+final
print cmd
print(cmd)
outcmd = commands.getstatusoutput( cmd )
print outcmd[1]
print(outcmd[1])

cmd = "ls *.png"
outcmd = commands.getstatusoutput( cmd )

pngfiles = outcmd[1].split('\n')
print pngfiles
print(pngfiles)

cmd = "cp *.png "+os.path.dirname(output)
outcmd = commands.getstatusoutput( cmd )
Expand Down Expand Up @@ -409,7 +410,7 @@ def get_productionIOVs( directory ):
lines.append(br)
#lines.append('to be written'+end)
lines.append(processedruns[0]+', '+processedruns[1]+', '+processedruns[2])
print processedruns
print(processedruns)
lines.append(br)

lines.append('<h2>The Latest Tags</h2>'+end)
Expand Down
19 changes: 10 additions & 9 deletions RecoVertex/BeamSpotProducer/scripts/checkPayloads.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
import sys,os,commands,re
import xmlrpclib
from CommonMethods import *
Expand All @@ -9,7 +10,7 @@
try:
import simplejson as json
except:
print "Please set a crab environment in order to get the proper JSON lib"
print("Please set a crab environment in order to get the proper JSON lib")
sys.exit(1)

#####################################################################################
Expand Down Expand Up @@ -72,12 +73,12 @@ def getListOfRunsAndLumiFromRR(firstRun=-1,error=""):
break
except:
tries += 1
print "Trying to get run data. This fails only 2-3 times so don't panic yet...", tries, "/", maxAttempts
print("Trying to get run data. This fails only 2-3 times so don't panic yet...", tries, "/", maxAttempts)
time.sleep(1)
print "Exception type: ", sys.exc_info()[0]
print("Exception type: ", sys.exc_info()[0])
if tries==maxAttempts:
error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
print error;
print(error);
return {};

listOfRuns=[]
Expand All @@ -98,13 +99,13 @@ def getListOfRunsAndLumiFromRR(firstRun=-1,error=""):
break
except:
tries += 1
print "I was able to get the list of runs and now I am trying to access the detector status", tries, "/", maxAttempts
print("I was able to get the list of runs and now I am trying to access the detector status", tries, "/", maxAttempts)
time.sleep(1)
print "Exception type: ", sys.exc_info()[0]
print("Exception type: ", sys.exc_info()[0])

if tries==maxAttempts:
error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
print error;
print(error);
return {};

#This is the original and shold work in the furture as soon as the server will be moved to a more powerfull PC
Expand Down Expand Up @@ -190,7 +191,7 @@ def main():

knownMissingRunList = [132573,132958,133081,133242,133472,133473,136290,138560,138562,139455,140133,140182,142461,142465,142503,142653,143977,148859]
tagName = "BeamSpotObjects_2009" + dbBase + sigmaZ + "_v" + tagNumber + "_offline"
print "Checking payloads for tag " + tagName
print("Checking payloads for tag " + tagName)
listOfRunsAndLumi = {};
#listOfRunsAndLumi = getListOfRunsAndLumiFromRR(-1);
if(not listOfRunsAndLumi):
Expand Down Expand Up @@ -220,7 +221,7 @@ def main():
if run in knownMissingRunList :
extraMsg = " but this run is know to be bad " #+ runErrors[run]
if not printExtra: continue
print "Run: " + str(run) + " is missing for DB tag " + tagName + extraMsg
print("Run: " + str(run) + " is missing for DB tag " + tagName + extraMsg)


if __name__ == "__main__":
Expand Down
21 changes: 11 additions & 10 deletions RecoVertex/BeamSpotProducer/scripts/checkRuns.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
import sys,os,commands,re
import xmlrpclib
from CommonMethods import *
Expand All @@ -8,7 +9,7 @@
try:
import simplejson as json
except:
print "Please set a crab environment in order to get the proper JSON lib"
print("Please set a crab environment in order to get the proper JSON lib")
sys.exit(1)

#####################################################################################
Expand Down Expand Up @@ -46,12 +47,12 @@ def getListOfRunsAndLumiFromRR(firstRun=-1,error=""):
break
except:
tries += 1
print "Trying to get run data. This fails only 2-3 times so don't panic yet...", tries, "/", maxAttempts
print("Trying to get run data. This fails only 2-3 times so don't panic yet...", tries, "/", maxAttempts)
time.sleep(1)
print "Exception type: ", sys.exc_info()[0]
print("Exception type: ", sys.exc_info()[0])
if tries==maxAttempts:
error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
print error;
print(error);
return {};

listOfRuns=[]
Expand All @@ -72,13 +73,13 @@ def getListOfRunsAndLumiFromRR(firstRun=-1,error=""):
break
except:
tries += 1
print "I was able to get the list of runs and now I am trying to access the detector status", tries, "/", maxAttempts
print("I was able to get the list of runs and now I am trying to access the detector status", tries, "/", maxAttempts)
time.sleep(1)
print "Exception type: ", sys.exc_info()[0]
print("Exception type: ", sys.exc_info()[0])

if tries==maxAttempts:
error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
print error;
print(error);
return {};

selected_dcs={}
Expand Down Expand Up @@ -144,7 +145,7 @@ def main():
if not run in runsAndLumisProcessed:
runsAndLumisProcessed[run] = []
if begLumi in runsAndLumisProcessed[run]:
print "Lumi " + str(begLumi) + " in event " + str(run) + " already exist. This MUST not happen but right now I will ignore this lumi!"
print("Lumi " + str(begLumi) + " in event " + str(run) + " already exist. This MUST not happen but right now I will ignore this lumi!")
else:
runsAndLumisProcessed[run].append(begLumi)
file.close()
Expand All @@ -156,12 +157,12 @@ def main():
#print str(counter) + "->" + str(lumi)
#counter += 1
if(run not in runFiles):
print "Can't find run", run, "in the files!"
print("Can't find run", run, "in the files!")
break ;
elif( not lumi in runsAndLumisProcessed[run]):
missingLumis.append(lumi)
if(len(missingLumis) != 0):
print "In run", run, "these lumis are missing ->", missingLumis
print("In run", run, "these lumis are missing ->", missingLumis)


if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions RecoVertex/BeamSpotProducer/scripts/copyAndRename.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
import sys,os,commands
from CommonMethods import *
def main():
Expand All @@ -11,7 +12,7 @@ def main():
fileList = ls(sourceDir,".txt")
if not os.path.isdir(destDir):
error = "WARNING: destination directory doesn't exist! Creating it..."
print error
print(error)
os.mkdir(destDir)
copiedFiles = cp(sourceDir,destDir,fileList)

Expand All @@ -34,12 +35,12 @@ def main():
newFileName = fileName.replace("1_.txt",str(runNumber)+"_1_.txt")
if fileName != newFileName:
aCmd = "mv " + destDir + fileName + " " + destDir + newFileName
print aCmd
print(aCmd)
output = commands.getstatusoutput(aCmd)
if output[0] != 0:
print output[1]
print(output[1])
else:
print "WARNING couldn't find keyword None in file " + fileName
print("WARNING couldn't find keyword None in file " + fileName)



Expand Down
3 changes: 2 additions & 1 deletion RecoVertex/BeamSpotProducer/scripts/copyFiles.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
import sys,os,commands
from CommonMethods import *

Expand All @@ -7,7 +8,7 @@ def main():
error = "Usage: copyFiles.py fromDir destDir (optional filter)"
exit(error)
fromDir = sys.argv[1]
print fromDir
print(fromDir)
if (fromDir[len(fromDir)-1] != '/'):
fromDir += '/'
destDir = sys.argv[2] + "/"
Expand Down