CMS 3D CMS Logo

Classes | Functions

uploader Namespace Reference

Classes

class  FileObj

Functions

def main

Function Documentation

def uploader::main ( )

Definition at line 13 of file uploader.py.

00014           :
00015     payloadDir = "./archive_repro_13May/payloads/"
00016     aCommand  = "ls " + payloadDir + " | grep BeamSpotObjects_2009_LumiBased_ | grep txt"           
00017     output = commands.getstatusoutput( aCommand )
00018     listOfFiles = output[1].split('\n')                                                                              
00019     print listOfFiles
00020     finalList = {}
00021     for fileName in listOfFiles:
00022         file = open(payloadDir + fileName)
00023         for line in file:
00024             if line.find("since") != -1:
00025                 tmpObj = FileObj()
00026                 tmpObj.run = unpackLumiid(long(line.split(' ')[1]))["run"]
00027                 tmpObj.iovSince = line.split(' ')[1].replace('\n','')
00028                 tmpObj.fileName = fileName
00029                 finalList[tmpObj.run] = tmpObj
00030                 file.close()
00031                 break
00032 
00033     sortedKeys = finalList.keys()
00034     sortedKeys.sort()
00035 
00036     databaseTag = ''
00037     regExp = re.search('(\D+)(\d+)_(\d+)_(\w+)',listOfFiles[0])
00038     if regExp:
00039         databaseTag = regExp.group(4)
00040     else:
00041         exit("Can't find reg exp")
00042 
00043     uuid = commands.getstatusoutput('uuidgen -t')[1]
00044     final_sqlite_file_name = databaseTag + '@' + uuid
00045     megaNumber = "18446744073709551615"
00046     print final_sqlite_file_name
00047     for run in sortedKeys:
00048         appendSqliteFile(final_sqlite_file_name + ".db", payloadDir+finalList[run].fileName.replace(".txt",".db"), databaseTag, finalList[run].iovSince, megaNumber,payloadDir)
00049         print finalList[run].fileName.replace(".txt",".db")
00050     aCommand  = "cp " + payloadDir + finalList[sortedKeys[0]].fileName + " " + payloadDir + final_sqlite_file_name + ".txt"
00051     output = commands.getstatusoutput( aCommand )
00052     dropbox = "/DropBox"
00053     print sortedKeys[0]
00054     print finalList[sortedKeys[0]].fileName
00055 #    uploadSqliteFile(payloadDir, final_sqlite_file_name, dropbox)
00056             
00057 
00058