Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #G.Benelli and Arun Mittal
- #Oct 3 2015
- #Quick script to split a large sqlite file (holding all of our Noise payloads (Run1+Run2) into a set of smaller ones.
- #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
- #a single recent noise payload seem to weight 20MB, and at most one will have 5 payloads for 5 IOVs.
- import subprocess
- #Input IOVs:
- #Reference for the use of subprocess Popen to execute a command:
- #subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
- #Let's prepare a container for the list of IOVs:
- IOVs=[]
- 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\
- derr=subprocess.STDOUT).stdout.readlines():
- if "SiPixelQuality " in line:
- #print line.split()
- if "2019" in line:
- IOVs.append((line.split()[3].strip(')')).strip('('))
- #print line
- print IOVs
- print "There are %s IOVs!"%len(IOVs)
- 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))]
- RelevantIOVs.append((RelevantIOVs[-1][2],IOVs[-1],IOVs[-1]))
- print RelevantIOVs
- for i,splitIOVs in enumerate(RelevantIOVs):
- begin=splitIOVs[0]
- end=splitIOVs[1]
- upperLimit=splitIOVs[1]
- print i,begin,end,upperLimit
- command="conddb_import -f sqlite:SiPixelQualityFromDbRcd_prompt_Ultralegacy2017_v0_mc.db -c sqlite:SiPixelQualityFromDbRcd_prompt_"+begin+"_"+end+".db -i SiPixelQualityFromDbRcd_prompt_Ultralegacy201\
- 7_v0_mc -t SiPixelQualityFromDbRcd_prompt_Ultralegacy2017_v0_mc.db -b "+begin+" -e "+end
- print command
- #Now if we want to execute it inside Python uncomment the following two lines:
- STDOUT=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
- print STDOUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement