Advertisement
Guest User

Untitled

a guest
May 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #G.Benelli and Arun Mittal
  3. #Oct 3 2015
  4. #Quick script to split a large sqlite file (holding all of our Noise payloads (Run1+Run2) into a set of smaller ones.
  5. #Trying to keep the size below 100MB to avoid dropbox issues, we decided after a few test to go for 5 IOVs, the reason being that
  6. #a single recent noise payload seem to weight 20MB, and at most one will have 5 payloads for 5 IOVs.
  7.  
  8. import subprocess
  9. #Input IOVs:
  10. #Reference for the use of subprocess Popen to execute a command:
  11. #subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
  12. #Let's prepare a container for the list of IOVs:
  13.  
  14. IOVs=[]
  15. for line in subprocess.Popen("conddb --noLimit --db SiPixelQualityFromDbRcd_prompt_Ultralegacy2017_v0_mc.db list SiPixelQualityFromDbRcd_prompt_Ultralegacy2017_v0_mc",shell=True,stdout=subprocess.PIPE,st\
  16. derr=subprocess.STDOUT).stdout.readlines():
  17. if "SiPixelQuality " in line:
  18. #print line.split()
  19. if "2019" in line:
  20. IOVs.append((line.split()[3].strip(')')).strip('('))
  21. #print line
  22. print IOVs
  23. print "There are %s IOVs!"%len(IOVs)
  24. RelevantIOVs=[(IOV,IOVs[IOVs.index(IOV)+199],IOVs[IOVs.index(IOV)+200]) for IOV in IOVs if IOVs.index(IOV)==0 or ((IOVs.index(IOV))%200==0 and (IOVs.index(IOV)+200)<len(IOVs))]
  25. RelevantIOVs.append((RelevantIOVs[-1][2],IOVs[-1],IOVs[-1]))
  26.  
  27. print RelevantIOVs
  28. for i,splitIOVs in enumerate(RelevantIOVs):
  29. begin=splitIOVs[0]
  30. end=splitIOVs[1]
  31. upperLimit=splitIOVs[1]
  32. print i,begin,end,upperLimit
  33. command="conddb_import -f sqlite:SiPixelQualityFromDbRcd_prompt_Ultralegacy2017_v0_mc.db -c sqlite:SiPixelQualityFromDbRcd_prompt_"+begin+"_"+end+".db -i SiPixelQualityFromDbRcd_prompt_Ultralegacy201\
  34. 7_v0_mc -t SiPixelQualityFromDbRcd_prompt_Ultralegacy2017_v0_mc.db -b "+begin+" -e "+end
  35. print command
  36.  
  37. #Now if we want to execute it inside Python uncomment the following two lines:
  38. STDOUT=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
  39. print STDOUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement