Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:01

0001 import subprocess
0002 import sys
0003 import os
0004 def submit(dataset, run):
0005     cfg=""
0006     with open("crabConfig.py","r") as f:
0007         cfg=f.readlines()
0008         cfg[0]="runNumber = "+str(run)+'\n'
0009         cfg[1]="dataset = "+'\"'+str(dataset)+'\"\n'
0010         
0011     with open("crabConfig.py","w") as f:
0012         f.writelines(cfg)
0013             
0014         
0015     #proc_id=subprocess.Popen(["crab", "submit", "-c", "crabConfig"+str(run)+".py"],start_new_session=True,stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
0016     subprocess.run(["crab", "submit", "-c", "crabConfig.py"],stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
0017     return proc_id
0018 
0019 proc_id=[]
0020 runs=[]
0021 submit_child=os.fork()
0022 if(submit_child==0):
0023     if sys.argv[2]=="range":
0024         for run in range(int(sys.argv[3]),int(sys.argv[4])+1):
0025             runs.append(run)
0026             proc_id.append(submit(sys.argv[1], run))
0027     else:
0028         for run in sys.argv[2:]:
0029             runs.append(run)
0030             proc_id.append(submit(sys.argv[1], run))
0031         
0032 else:
0033     print("submission process detached")
0034