CMS 3D CMS Logo

Functions | Variables

cmsLHEtoEOSManager Namespace Reference

Functions

def articleExist
def fileUpload
def findXrdDir
def lastArticle

Variables

string __version__ = "$Revision: 1.12 $"
string action = 'store_true'
string default = ''
string defaultEOScpCommand = 'xrdcp -np '
string defaultEOSfeCommand = 'xrd eoscms existfile '
string defaultEOSlistCommand = 'xrd eoscms dirlist '
string defaultEOSLoadPath = 'root://eoscms/'
string defaultEOSmkdirCommand = 'xrd eoscms mkdir '
string defaultEOSRootPath = '/eos/cms/store/lhe'
string dest = 'fileList'
tuple exeCompression = subprocess.Popen(["/bin/sh","-c",theCompressionCommand])
tuple exeFullList = subprocess.Popen(["/bin/sh","-c",theCommand])
tuple exeList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
tuple exeUpload = subprocess.Popen(["/bin/sh","-c",theCommand])
string help = 'LHE local file list to be uploaded, separated by ","'
string listPath = '/'
int newArt = 0
tuple oldArt = lastArticle()
tuple parser = optparse.OptionParser(usage)
 reallyDoIt = notoptions.dryRun
string theCommand = ' '
list theCompressedFilesList = []
string theCompressionCommand = 'xz '
tuple theList = options.fileList.split(',')
string uploadPath = ''
string usage = 'cmsLHEtoEOSManager.py <options>'

Function Documentation

def cmsLHEtoEOSManager::articleExist (   artId)

Definition at line 25 of file cmsLHEtoEOSManager.py.

00026                        :
00027 
00028     itExists = False
00029     theCommand = defaultEOSlistCommand+' '+defaultEOSRootPath
00030     dirList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
00031     for line in dirList.stdout.readlines():
00032         if findXrdDir(line) == str(artId): 
00033             itExists = True
00034 
00035     return itExists

def cmsLHEtoEOSManager::fileUpload (   uploadPath,
  lheList,
  reallyDoIt 
)

Definition at line 52 of file cmsLHEtoEOSManager.py.

00053                                               :
00054 
00055     inUploadScript = ''
00056 
00057     for f in lheList:
00058         realFileName = f.split('/')[-1]
00059         # Check the file existence
00060         newFileName = uploadPath+'/'+str(realFileName)
00061         addFile = True
00062         additionalOption = ''  
00063         theCommand = defaultEOSfeCommand+' '+newFileName
00064         exeFullList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
00065         result = exeFullList.stdout.readlines()
00066         if result[0].rstrip('\n') == 'The file exists.':
00067             addFile = False
00068             print 'File '+newFileName+' already exists: do you want to overwrite? [y/n]'
00069             reply = raw_input()
00070             if reply == 'y' or reply == 'Y':
00071                 addFile = True
00072                 additionalOption = ' -f '
00073                 print ''
00074                 print 'Overwriting file '+newFileName+'\n'
00075         # add the file
00076         if addFile:
00077             print 'Adding file '+str(f)+'\n'
00078             inUploadScript += defaultEOScpCommand+additionalOption+' '+str(f)+' '+defaultEOSLoadPath+uploadPath+'/'+str(realFileName)+'\n'
00079 
00080 # launch the upload shell script        
00081 
00082     print '\n Launching upload script \n'+inUploadScript+'\n at '+time.asctime(time.localtime(time.time()))+' ...\n'
00083     if reallyDoIt:  
00084       exeRealUpload = subprocess.Popen(["/bin/sh","-c",inUploadScript])
00085       exeRealUpload.communicate()
00086     print '\n Upload ended at '+time.asctime(time.localtime(time.time()))

def cmsLHEtoEOSManager::findXrdDir (   theDirRecord)

Definition at line 17 of file cmsLHEtoEOSManager.py.

00018                             :
00019 
00020     elements = theDirRecord.split(' ')
00021     if len(elements) > 1:
00022         return elements[-1].rstrip('\n').split('/')[-1]
00023     else:
00024         return None

def cmsLHEtoEOSManager::lastArticle ( )

Definition at line 36 of file cmsLHEtoEOSManager.py.

00037                  :
00038 
00039     artList = [0]
00040 
00041     theCommand = defaultEOSlistCommand+' '+defaultEOSRootPath
00042     dirList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
00043     for line in dirList.stdout.readlines():
00044         try:
00045             if line.rstrip('\n') != '':
00046                 artList.append(int(findXrdDir(line)))
00047         except:
00048             break
00049 
00050     return max(artList)
00051 


Variable Documentation

string cmsLHEtoEOSManager::__version__ = "$Revision: 1.12 $"

Definition at line 3 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::action = 'store_true'

Definition at line 103 of file cmsLHEtoEOSManager.py.

Definition at line 98 of file cmsLHEtoEOSManager.py.

Definition at line 15 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::defaultEOSfeCommand = 'xrd eoscms existfile '

Definition at line 14 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::defaultEOSlistCommand = 'xrd eoscms dirlist '

Definition at line 12 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::defaultEOSLoadPath = 'root://eoscms/'

Definition at line 11 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::defaultEOSmkdirCommand = 'xrd eoscms mkdir '

Definition at line 13 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::defaultEOSRootPath = '/eos/cms/store/lhe'

Definition at line 10 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::dest = 'fileList'

Definition at line 99 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager::exeCompression = subprocess.Popen(["/bin/sh","-c",theCompressionCommand])

Definition at line 171 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager::exeFullList = subprocess.Popen(["/bin/sh","-c",theCommand])

Definition at line 221 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager::exeList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)

Definition at line 208 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager::exeUpload = subprocess.Popen(["/bin/sh","-c",theCommand])

Definition at line 191 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::help = 'LHE local file list to be uploaded, separated by ","'

Definition at line 97 of file cmsLHEtoEOSManager.py.

Definition at line 206 of file cmsLHEtoEOSManager.py.

Definition at line 179 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager::oldArt = lastArticle()

Definition at line 185 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager::parser = optparse.OptionParser(usage)

Definition at line 95 of file cmsLHEtoEOSManager.py.

cmsLHEtoEOSManager::reallyDoIt = notoptions.dryRun

Definition at line 139 of file cmsLHEtoEOSManager.py.

Definition at line 189 of file cmsLHEtoEOSManager.py.

Definition at line 160 of file cmsLHEtoEOSManager.py.

Definition at line 170 of file cmsLHEtoEOSManager.py.

cmsLHEtoEOSManager::theList = options.fileList.split(',')

Definition at line 159 of file cmsLHEtoEOSManager.py.

Referenced by MuonAlignment::recursiveList().

Definition at line 180 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager::usage = 'cmsLHEtoEOSManager.py <options>'

Definition at line 94 of file cmsLHEtoEOSManager.py.