CMS 3D CMS Logo

uploader.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 import sys,os,commands
4 from CommonMethods import *
5 
6 class FileObj:
7  def __init__(self):
8  self.run = 0
9  self.iovSince = 0
10  self.fileName = ''
11 
12 
13 
14 def main():
15  payloadDir = "./archive_repro_13May/payloads/"
16  aCommand = "ls " + payloadDir + " | grep BeamSpotObjects_2009_LumiBased_ | grep txt"
17  output = commands.getstatusoutput( aCommand )
18  listOfFiles = output[1].split('\n')
19  print(listOfFiles)
20  finalList = {}
21  for fileName in listOfFiles:
22  file = open(payloadDir + fileName)
23  for line in file:
24  if line.find("since") != -1:
25  tmpObj = FileObj()
26  tmpObj.run = unpackLumiid(long(line.split(' ')[1]))["run"]
27  tmpObj.iovSince = line.split(' ')[1].replace('\n','')
28  tmpObj.fileName = fileName
29  finalList[tmpObj.run] = tmpObj
30  file.close()
31  break
32 
33  sortedKeys = sorted(finalList.keys())
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()
uploader.FileObj
Definition: uploader.py:6
uploader.FileObj.iovSince
iovSince
Definition: uploader.py:9
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
uploader.main
def main()
Definition: uploader.py:14
uploader.FileObj.__init__
def __init__(self)
Definition: uploader.py:7
uploader.FileObj.run
run
Definition: uploader.py:8
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
uploader.FileObj.fileName
fileName
Definition: uploader.py:10
main
Definition: main.py:1
timeUnitHelper.unpackLumiid
def unpackLumiid(i)
Definition: timeUnitHelper.py:42
CommonMethods.appendSqliteFile
def appendSqliteFile(combinedSqliteFileName, sqliteFileName, tagName, IOVSince, IOVTill, tmpDir="/tmp/")
Definition: CommonMethods.py:931
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444