CMS 3D CMS Logo

Functions
cmsLHEtoEOSManager Namespace Reference

Functions

def articleExist (artId)
 
def fileUpload (uploadPath, lheList, checkSumList, reallyDoIt)
 
def findXrdDir (theDirRecord)
 
def lastArticle ()
 

Function Documentation

def cmsLHEtoEOSManager.articleExist (   artId)

Definition at line 27 of file cmsLHEtoEOSManager.py.

References findXrdDir(), and harvestTrackValidationPlots.str.

Referenced by fileUpload().

27 def articleExist(artId):
28 
29  itExists = False
30  theCommand = defaultEOSlistCommand+' '+defaultEOSRootPath
31  dirList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
32  for line in dirList.stdout.readlines():
33  if findXrdDir(line) == str(artId):
34  itExists = True
35 
36  return itExists
37 
def findXrdDir(theDirRecord)
def cmsLHEtoEOSManager.fileUpload (   uploadPath,
  lheList,
  checkSumList,
  reallyDoIt 
)

Definition at line 54 of file cmsLHEtoEOSManager.py.

References articleExist(), findXrdDir(), reco.if(), lastArticle(), and harvestTrackValidationPlots.str.

54 def fileUpload(uploadPath,lheList, checkSumList, reallyDoIt):
55 
56  inUploadScript = ''
57  index = 0
58  for f in lheList:
59  realFileName = f.split('/')[-1]
60  # Check the file existence
61  newFileName = uploadPath+'/'+str(realFileName)
62  addFile = True
63  additionalOption = ''
64  theCommand = defaultEOSfeCommand+' '+newFileName
65  exeFullList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
66  result = exeFullList.stdout.readlines()
67  if result[0].rstrip('\n') == 'The file exists.':
68  addFile = False
69  print 'File '+newFileName+' already exists: do you want to overwrite? [y/n]'
70  reply = raw_input()
71  if reply == 'y' or reply == 'Y':
72  addFile = True
73  additionalOption = ' -f '
74  print ''
75  print 'Overwriting file '+newFileName+'\n'
76  # add the file
77  if addFile:
78 # print 'Adding file '+str(f)+'\n'
79  inUploadScript = defaultEOScpCommand + additionalOption + ' ' + str(f) + ' ' + defaultEOSLoadPath+uploadPath + '/' + str(realFileName)
80  print 'Uploading file %s...' % str(f)
81  if reallyDoIt:
82  exeRealUpload = subprocess.Popen(["/bin/sh","-c",inUploadScript])
83  exeRealUpload.communicate()
84  eosCheckSumCommand = '/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select find --checksum ' + uploadPath + '/' + str(realFileName) + ' | awk \'{print $2}\' | cut -d= -f2'
85  exeEosCheckSum = subprocess.Popen(eosCheckSumCommand ,shell=True, stdout=subprocess.PIPE)
86  EosCheckSum = exeEosCheckSum.stdout.read()
87  assert exeEosCheckSum.wait() == 0
88  # print 'checksum: eos = ' + EosCheckSum + 'orig file = ' + checkSumList[index] + '\n'
89  if checkSumList[index] not in EosCheckSum:
90  print 'WARNING! The checksum for file ' + str(realFileName) + ' in EOS\n'
91  print EosCheckSum + '\n'
92  print 'does not match the checksum of the original one\n'
93  print checkSumList[index] + '\n'
94  print 'please try to re-upload file ' + str(realFileName) + ' to EOS.\n'
95  else:
96  print 'Checksum OK for file ' + str(realFileName)
97  index = index+1
98 
99 # launch the upload shell script
100 
101 # print '\n Launching upload script \n'+inUploadScript+'\n at '+time.asctime(time.localtime(time.time()))+' ...\n'
102 # if reallyDoIt:
103 # exeRealUpload = subprocess.Popen(["/bin/sh","-c",inUploadScript])
104 # exeRealUpload.communicate()
105  print '\n Upload ended at '+time.asctime(time.localtime(time.time()))
106 
def fileUpload(uploadPath, lheList, checkSumList, reallyDoIt)
def cmsLHEtoEOSManager.findXrdDir (   theDirRecord)

Definition at line 19 of file cmsLHEtoEOSManager.py.

References split.

Referenced by articleExist(), fileUpload(), and lastArticle().

19 def findXrdDir(theDirRecord):
20 
21  elements = theDirRecord.split(' ')
22  if len(elements) > 1:
23  return elements[-1].rstrip('\n').split('/')[-1]
24  else:
25  return None
26 
def findXrdDir(theDirRecord)
double split
Definition: MVATrainer.cc:139
def cmsLHEtoEOSManager.lastArticle ( )

Definition at line 38 of file cmsLHEtoEOSManager.py.

References findXrdDir(), createfilelist.int, and hpstanc_transforms.max.

Referenced by fileUpload().

39 
40  artList = [0]
41 
42  theCommand = defaultEOSlistCommand+' '+defaultEOSRootPath
43  dirList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
44  for line in dirList.stdout.readlines():
45  try:
46  if line.rstrip('\n') != '':
47  artList.append(int(findXrdDir(line)))
48  except:
49  break
50 
51  return max(artList)
52 
53 
def findXrdDir(theDirRecord)