CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 exeCheckIntegrity = subprocess.Popen(["/bin/sh","-c", theCheckIntegrityCommand])
 
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 ","'
 
tuple intCode = exeCheckIntegrity.wait()
 
string listPath = defaultEOSRootPath+'/'
 
int newArt = 0
 
tuple oldArt = lastArticle()
 
tuple parser = optparse.OptionParser(usage)
 
 reallyDoIt = notoptions.dryRun
 
string theCheckIntegrityCommand = 'xmllint -noout '
 
string theCommand = defaultEOSmkdirCommand+' '
 
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.

References findXrdDir().

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

Definition at line 52 of file cmsLHEtoEOSManager.py.

52 
53 def fileUpload(uploadPath,lheList, reallyDoIt):
54 
55  inUploadScript = ''
56 
57  for f in lheList:
58  realFileName = f.split('/')[-1]
59  # Check the file existence
60  newFileName = uploadPath+'/'+str(realFileName)
61  addFile = True
62  additionalOption = ''
63  theCommand = defaultEOSfeCommand+' '+newFileName
64  exeFullList = subprocess.Popen(["/bin/sh","-c",theCommand], stdout=subprocess.PIPE)
65  result = exeFullList.stdout.readlines()
66  if result[0].rstrip('\n') == 'The file exists.':
67  addFile = False
68  print 'File '+newFileName+' already exists: do you want to overwrite? [y/n]'
69  reply = raw_input()
70  if reply == 'y' or reply == 'Y':
71  addFile = True
72  additionalOption = ' -f '
73  print ''
74  print 'Overwriting file '+newFileName+'\n'
75  # add the file
76  if addFile:
77  print 'Adding file '+str(f)+'\n'
78  inUploadScript += defaultEOScpCommand+additionalOption+' '+str(f)+' '+defaultEOSLoadPath+uploadPath+'/'+str(realFileName)+'\n'
79 
80 # launch the upload shell script
81 
82  print '\n Launching upload script \n'+inUploadScript+'\n at '+time.asctime(time.localtime(time.time()))+' ...\n'
83  if reallyDoIt:
84  exeRealUpload = subprocess.Popen(["/bin/sh","-c",inUploadScript])
85  exeRealUpload.communicate()
86  print '\n Upload ended at '+time.asctime(time.localtime(time.time()))
def cmsLHEtoEOSManager.findXrdDir (   theDirRecord)

Definition at line 17 of file cmsLHEtoEOSManager.py.

References split.

Referenced by articleExist(), and lastArticle().

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

Definition at line 36 of file cmsLHEtoEOSManager.py.

References findXrdDir(), and max().

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

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.

int cmsLHEtoEOSManager.default = ''

Definition at line 98 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager.defaultEOScpCommand = 'xrdcp -np '

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.exeCheckIntegrity = subprocess.Popen(["/bin/sh","-c", theCheckIntegrityCommand])

Definition at line 174 of file cmsLHEtoEOSManager.py.

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

Definition at line 181 of file cmsLHEtoEOSManager.py.

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

Definition at line 231 of file cmsLHEtoEOSManager.py.

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

Definition at line 218 of file cmsLHEtoEOSManager.py.

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

Definition at line 201 of file cmsLHEtoEOSManager.py.

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

Definition at line 97 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager.intCode = exeCheckIntegrity.wait()

Definition at line 175 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager.listPath = defaultEOSRootPath+'/'

Definition at line 216 of file cmsLHEtoEOSManager.py.

int cmsLHEtoEOSManager.newArt = 0

Definition at line 189 of file cmsLHEtoEOSManager.py.

tuple cmsLHEtoEOSManager.oldArt = lastArticle()

Definition at line 195 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.

string cmsLHEtoEOSManager.theCheckIntegrityCommand = 'xmllint -noout '

Definition at line 173 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager.theCommand = defaultEOSmkdirCommand+' '

Definition at line 199 of file cmsLHEtoEOSManager.py.

list cmsLHEtoEOSManager.theCompressedFilesList = []

Definition at line 160 of file cmsLHEtoEOSManager.py.

string cmsLHEtoEOSManager.theCompressionCommand = 'xz '

Definition at line 180 of file cmsLHEtoEOSManager.py.

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

Definition at line 159 of file cmsLHEtoEOSManager.py.

Referenced by MuonAlignment.recursiveList().

string cmsLHEtoEOSManager.uploadPath = ''

Definition at line 190 of file cmsLHEtoEOSManager.py.

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

Definition at line 94 of file cmsLHEtoEOSManager.py.