Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-27 04:18:17

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