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 28 of file cmsLHEtoEOSManager.py.

References findXrdDir(), and str.

Referenced by fileUpload().

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

Definition at line 55 of file cmsLHEtoEOSManager.py.

References articleExist(), findXrdDir(), lastArticle(), edm.print(), and str.

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

Definition at line 20 of file cmsLHEtoEOSManager.py.

References split.

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

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

Definition at line 39 of file cmsLHEtoEOSManager.py.

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

Referenced by fileUpload().

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