CMS 3D CMS Logo

uploader.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import sys,os,commands
3 from CommonMethods import *
4 
5 class FileObj:
6  def __init__(self):
7  self.run = 0
8  self.iovSince = 0
9  self.fileName = ''
10 
11 
12 
13 def main():
14  payloadDir = "./archive_repro_13May/payloads/"
15  aCommand = "ls " + payloadDir + " | grep BeamSpotObjects_2009_LumiBased_ | grep txt"
16  output = commands.getstatusoutput( aCommand )
17  listOfFiles = output[1].split('\n')
18  print listOfFiles
19  finalList = {}
20  for fileName in listOfFiles:
21  file = open(payloadDir + fileName)
22  for line in file:
23  if line.find("since") != -1:
24  tmpObj = FileObj()
25  tmpObj.run = unpackLumiid(long(line.split(' ')[1]))["run"]
26  tmpObj.iovSince = line.split(' ')[1].replace('\n','')
27  tmpObj.fileName = fileName
28  finalList[tmpObj.run] = tmpObj
29  file.close()
30  break
31 
32  sortedKeys = finalList.keys()
33  sortedKeys.sort()
34 
35  databaseTag = ''
36  regExp = re.search('(\D+)(\d+)_(\d+)_(\w+)',listOfFiles[0])
37  if regExp:
38  databaseTag = regExp.group(4)
39  else:
40  exit("Can't find reg exp")
41 
42  uuid = commands.getstatusoutput('uuidgen -t')[1]
43  final_sqlite_file_name = databaseTag + '@' + uuid
44  megaNumber = "18446744073709551615"
45  print final_sqlite_file_name
46  for run in sortedKeys:
47  appendSqliteFile(final_sqlite_file_name + ".db", payloadDir+finalList[run].fileName.replace(".txt",".db"), databaseTag, finalList[run].iovSince, megaNumber,payloadDir)
48  print finalList[run].fileName.replace(".txt",".db")
49  aCommand = "cp " + payloadDir + finalList[sortedKeys[0]].fileName + " " + payloadDir + final_sqlite_file_name + ".txt"
50  output = commands.getstatusoutput( aCommand )
51  dropbox = "/DropBox"
52  print sortedKeys[0]
53  print finalList[sortedKeys[0]].fileName
54 # uploadSqliteFile(payloadDir, final_sqlite_file_name, dropbox)
55 
56 
57 
58 
59 if __name__ == "__main__":
60  main()
def replace(string, replacements)
def appendSqliteFile(combinedSqliteFileName, sqliteFileName, tagName, IOVSince, IOVTill, tmpDir="/tmp/")
def main()
Definition: uploader.py:13
def __init__(self)
Definition: uploader.py:6
Definition: main.py:1
double split
Definition: MVATrainer.cc:139