Go to the documentation of this file.00001
00002 import sys,os,commands
00003 from CommonMethods import *
00004
00005 class FileObj:
00006 def __init__(self):
00007 self.run = 0
00008 self.iovSince = 0
00009 self.fileName = ''
00010
00011
00012
00013 def main():
00014 payloadDir = "./archive_repro_13May/payloads/"
00015 aCommand = "ls " + payloadDir + " | grep BeamSpotObjects_2009_LumiBased_ | grep txt"
00016 output = commands.getstatusoutput( aCommand )
00017 listOfFiles = output[1].split('\n')
00018 print listOfFiles
00019 finalList = {}
00020 for fileName in listOfFiles:
00021 file = open(payloadDir + fileName)
00022 for line in file:
00023 if line.find("since") != -1:
00024 tmpObj = FileObj()
00025 tmpObj.run = unpackLumiid(long(line.split(' ')[1]))["run"]
00026 tmpObj.iovSince = line.split(' ')[1].replace('\n','')
00027 tmpObj.fileName = fileName
00028 finalList[tmpObj.run] = tmpObj
00029 file.close()
00030 break
00031
00032 sortedKeys = finalList.keys()
00033 sortedKeys.sort()
00034
00035 databaseTag = ''
00036 regExp = re.search('(\D+)(\d+)_(\d+)_(\w+)',listOfFiles[0])
00037 if regExp:
00038 databaseTag = regExp.group(4)
00039 else:
00040 exit("Can't find reg exp")
00041
00042 uuid = commands.getstatusoutput('uuidgen -t')[1]
00043 final_sqlite_file_name = databaseTag + '@' + uuid
00044 megaNumber = "18446744073709551615"
00045 print final_sqlite_file_name
00046 for run in sortedKeys:
00047 appendSqliteFile(final_sqlite_file_name + ".db", payloadDir+finalList[run].fileName.replace(".txt",".db"), databaseTag, finalList[run].iovSince, megaNumber,payloadDir)
00048 print finalList[run].fileName.replace(".txt",".db")
00049 aCommand = "cp " + payloadDir + finalList[sortedKeys[0]].fileName + " " + payloadDir + final_sqlite_file_name + ".txt"
00050 output = commands.getstatusoutput( aCommand )
00051 dropbox = "/DropBox"
00052 print sortedKeys[0]
00053 print finalList[sortedKeys[0]].fileName
00054
00055
00056
00057
00058
00059 if __name__ == "__main__":
00060 main()