Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-27 03:18:06

0001 #!/usr/bin/env python3
0002 import sys,os,subprocess
0003 from CommonMethods import *
0004 
0005 class FileObj:
0006     def __init__(self):
0007         self.run      = 0
0008         self.iovSince = 0
0009         self.fileName = ''                 
0010 
0011                                                                         
0012 
0013 def main():
0014     payloadDir = "./archive_repro_13May/payloads/"
0015     aCommand  = "ls " + payloadDir + " | grep BeamSpotObjects_2009_LumiBased_ | grep txt"           
0016     output = subprocess.getstatusoutput( aCommand )
0017     listOfFiles = output[1].split('\n')                                                                              
0018     print(listOfFiles)
0019     finalList = {}
0020     for fileName in listOfFiles:
0021         file = open(payloadDir + fileName)
0022         for line in file:
0023             if line.find("since") != -1:
0024                 tmpObj = FileObj()
0025                 tmpObj.run = unpackLumiid(long(line.split(' ')[1]))["run"]
0026                 tmpObj.iovSince = line.split(' ')[1].replace('\n','')
0027                 tmpObj.fileName = fileName
0028                 finalList[tmpObj.run] = tmpObj
0029                 file.close()
0030                 break
0031 
0032     sortedKeys = sorted(finalList.keys())
0033 
0034     databaseTag = ''
0035     regExp = re.search('(\D+)(\d+)_(\d+)_(\w+)',listOfFiles[0])
0036     if regExp:
0037         databaseTag = regExp.group(4)
0038     else:
0039         exit("Can't find reg exp")
0040 
0041     uuid = subprocess.getstatusoutput('uuidgen -t')[1]
0042     final_sqlite_file_name = databaseTag + '@' + uuid
0043     megaNumber = "18446744073709551615"
0044     print(final_sqlite_file_name)
0045     for run in sortedKeys:
0046         appendSqliteFile(final_sqlite_file_name + ".db", payloadDir+finalList[run].fileName.replace(".txt",".db"), databaseTag, finalList[run].iovSince, megaNumber,payloadDir)
0047         print(finalList[run].fileName.replace(".txt",".db"))
0048     aCommand  = "cp " + payloadDir + finalList[sortedKeys[0]].fileName + " " + payloadDir + final_sqlite_file_name + ".txt"
0049     output = subprocess.getstatusoutput( aCommand )
0050     dropbox = "/DropBox"
0051     print(sortedKeys[0])
0052     print(finalList[sortedKeys[0]].fileName)
0053 #    uploadSqliteFile(payloadDir, final_sqlite_file_name, dropbox)
0054             
0055 
0056 
0057         
0058 if __name__ == "__main__":
0059     main()