CMS 3D CMS Logo

Functions | Variables

createPayload Namespace Reference

Functions

def copyToWorkflowdir
def mkWorkflowdir

Variables

string allbeam_file = "AllIOVs/"
tuple allfile = open( allbeam_file, 'a')
tuple alllines = mergedfile.readlines()
tuple alumi = line.split()
string alumis = ''
string arun = ''
tuple atime = line.split()
list beam_file = sortedlist[key]
 WRITE sqlite file.
list beam_file_tmp = workflowdirTmp+beam_file[beam_file.rfind('/')+1:]
list block = alllines[i * 23: (i+1)*23]
 checkType = tagType
string destDB = 'oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT'
tuple dfile = open(metadata_file,'w')
string dropbox = "/DropBox"
string final_sqlite_file_name = '@'
string iov_comment = 'Beam spot position'
string iov_since = '1'
string iov_since_first = '1'
string iov_till = ''
string IOVbase = 'runbase'
tuple keys = sortedlist.keys()
list line = block[0]
tuple listoffiles = copyToWorkflowdir(option.data)
tuple mergedfile = open(beam_file)
string metadata_file = '.txt'
tuple newtmpfile = open(beam_file_tmp,"w")
int nfile = 0
tuple npayloads = len(alllines)
string optionstring = ''
tuple readdb_template = os.getenv("CMSSW_BASE")
 skip = False
dictionary sortedlist = {}
string sqlite_file = '.db'
 READ and check sqlite file.
 sqlite_file_name = tagname+suffix
string suffix = "_"
string tagname = ''
string tagType = ''
string timetype = 'runnumber'
string tmp_datafilename = "tmp_datafile.txt"
string tmp_lumi_since = ""
string tmp_lumi_till = ""
string tmp_run = ""
tuple tmpfile = open(beam_file)
tuple total_files = len(keys)
tuple uuid = commands.getstatusoutput('uuidgen -t')
string workflowdir = 'test/workflow/'
string workflowdirArchive = 'archive/'
string workflowdirLastPayloads = 'lastPayloads/'
string workflowdirTmp = 'tmp/'
tuple writedb_template = os.getenv("CMSSW_BASE")

Function Documentation

def createPayload::copyToWorkflowdir (   path)

Definition at line 51 of file createPayload.py.

00052                            :
00053     global workflowdirArchive
00054     lsCommand      = ''
00055     cpCommand      = ''
00056     listoffiles    = []
00057     tmplistoffiles = []
00058     if path.find('castor') != -1:
00059         print "Getting files from castor ..."
00060         lsCommand = 'ns'
00061         cpCommand = 'rf'
00062     elif not os.path.exists(path):
00063         exit("ERROR: File or directory " + path + " doesn't exist") 
00064 
00065     if path[len(path)-4:len(path)] != '.txt':
00066         if path[len(path)-1] != '/':
00067             path = path + '/'
00068         
00069         aCommand  = lsCommand  + 'ls '+ path + " | grep .txt"
00070 
00071         tmpstatus = commands.getstatusoutput( aCommand )
00072         tmplistoffiles = tmpstatus[1].split('\n')
00073         if len(tmplistoffiles) == 1:
00074             if tmplistoffiles[0] == '':
00075                 exit('ERROR: No files found in directory ' + path)
00076             if tmplistoffiles[0].find('No such file or directory') != -1:
00077                 exit("ERROR: File or directory " + path + " doesn't exist") 
00078             
00079     else:
00080         tmplistoffiles.append(path[path.rfind('/')+1:len(path)])
00081         path = path[0:path.rfind('/')+1]
00082 
00083  
00084     archiveName = path
00085     if path == './':
00086         archiveName = os.getcwd() + '/'
00087         archiveName = archiveName[archiveName[:len(archiveName)-1].rfind('/')+1:len(archiveName)]
00088     if path[:len(path)-1].rfind('/') != -1:
00089         archiveName = path[path[:len(path)-1].rfind('/')+1:len(path)]
00090 
00091     workflowdirArchive = workflowdirArchive + archiveName
00092     if tagType != '' :
00093         workflowdirArchive = workflowdirArchive[:len(workflowdirArchive)-1] + '_' + tagType + '/'
00094     if not os.path.isdir(workflowdirArchive):
00095         os.mkdir(workflowdirArchive)
00096     elif(option.newarchive):
00097 #        tmpTime = str(datetime.datetime.now())
00098 #        tmpTime = tmpTime.replace(' ','-')
00099 #        tmpTime = tmpTime.replace('.','-')
00100 #        workflowdirArchive = workflowdirArchive[:len(workflowdirArchive)-1] + '_' + tmpTime + '/'
00101 #        os.mkdir(workflowdirArchive)
00102         for n in range(1,100000):
00103             tryDir = workflowdirArchive[:len(workflowdirArchive)-1] + '_' + str(n) + '/'
00104             if not os.path.isdir(tryDir):
00105                 workflowdirArchive = tryDir
00106                 os.mkdir(workflowdirArchive)
00107                 break
00108             elif n == 100000-1:
00109                 exit('ERROR: Unbelievable! do you ever clean ' + workflowdir + '?. I think you have to remove some directories!') 
00110                  
00111     for ifile in tmplistoffiles:
00112         if ifile.find('.txt') != -1:
00113             if os.path.isfile(workflowdirArchive+"/"+ifile):
00114                 if option.overwrite:
00115                     print "File " + ifile + " already exists in destination. We will overwrite it."
00116                 else:
00117                     print "File " + ifile + " already exists in destination. Keep original file."
00118                     listoffiles.append( workflowdirArchive + ifile )
00119                     continue
00120             listoffiles.append( workflowdirArchive + ifile )
00121             # copy to local disk
00122             aCommand = cpCommand + 'cp '+ path + ifile + " " + workflowdirArchive
00123             print " >> " + aCommand
00124             tmpstatus = commands.getstatusoutput( aCommand )
00125     return listoffiles

def createPayload::mkWorkflowdir ( )

Definition at line 126 of file createPayload.py.

00127                    :
00128     global workflowdir
00129     global workflowdirLastPayloads
00130     global workflowdirTmp
00131     global workflowdirArchive
00132     if not os.path.isdir(workflowdir):
00133         print "Making " + workflowdir + " directory..."
00134         os.mkdir(workflowdir)
00135 
00136     if not os.path.isdir(workflowdirLastPayloads):
00137         os.mkdir(workflowdirLastPayloads)
00138     else:
00139         os.system("rm -f "+ workflowdirLastPayloads + "*")
00140        
00141     if not os.path.isdir(workflowdirTmp):
00142         os.mkdir(workflowdirTmp)
00143     else:
00144         os.system("rm -f "+ workflowdirTmp + "*")
00145 
00146     if not os.path.isdir(workflowdirArchive):
00147         os.mkdir(workflowdirArchive)


Variable Documentation

string createPayload::allbeam_file = "AllIOVs/"

Definition at line 255 of file createPayload.py.

Definition at line 258 of file createPayload.py.

tuple createPayload::alllines = mergedfile.readlines()

Definition at line 216 of file createPayload.py.

tuple createPayload::alumi = line.split()

Definition at line 238 of file createPayload.py.

string createPayload::alumis = ''

Definition at line 230 of file createPayload.py.

tuple createPayload::arun = ''

Definition at line 229 of file createPayload.py.

tuple createPayload::atime = line.split()

Definition at line 223 of file createPayload.py.

WRITE sqlite file.

Definition at line 290 of file createPayload.py.

list createPayload::beam_file_tmp = workflowdirTmp+beam_file[beam_file.rfind('/')+1:]

Definition at line 300 of file createPayload.py.

list createPayload::block = alllines[i * 23: (i+1)*23]

Definition at line 219 of file createPayload.py.

Definition at line 382 of file createPayload.py.

Referenced by edm::checkDictionaries().

string createPayload::destDB = 'oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT'

Definition at line 270 of file createPayload.py.

Definition at line 371 of file createPayload.py.

string createPayload::dropbox = "/DropBox"

Definition at line 406 of file createPayload.py.

Definition at line 391 of file createPayload.py.

string createPayload::iov_comment = 'Beam spot position'

Definition at line 274 of file createPayload.py.

Definition at line 277 of file createPayload.py.

Definition at line 267 of file createPayload.py.

Definition at line 278 of file createPayload.py.

Definition at line 200 of file createPayload.py.

tuple createPayload::keys = sortedlist.keys()

Definition at line 249 of file createPayload.py.

Definition at line 222 of file createPayload.py.

tuple createPayload::listoffiles = copyToWorkflowdir(option.data)

Definition at line 208 of file createPayload.py.

Definition at line 215 of file createPayload.py.

Definition at line 285 of file createPayload.py.

Definition at line 301 of file createPayload.py.

Definition at line 266 of file createPayload.py.

Definition at line 217 of file createPayload.py.

Definition at line 48 of file createPayload.py.

tuple createPayload::readdb_template = os.getenv("CMSSW_BASE")

Definition at line 282 of file createPayload.py.

dictionary createPayload::sortedlist = {}

Definition at line 210 of file createPayload.py.

READ and check sqlite file.

Merge sqlite files CREATE payload for merged output

Definition at line 284 of file createPayload.py.

Definition at line 283 of file createPayload.py.

string createPayload::suffix = "_"

Definition at line 49 of file createPayload.py.

string createPayload::timetype = 'runnumber'

Definition at line 201 of file createPayload.py.

string createPayload::tmp_datafilename = "tmp_datafile.txt"

Definition at line 291 of file createPayload.py.

Definition at line 303 of file createPayload.py.

Definition at line 304 of file createPayload.py.

Definition at line 302 of file createPayload.py.

Definition at line 227 of file createPayload.py.

Referenced by BeamMonitor::FitAndFill().

Definition at line 268 of file createPayload.py.

tuple createPayload::uuid = commands.getstatusoutput('uuidgen -t')

Definition at line 390 of file createPayload.py.

string createPayload::workflowdir = 'test/workflow/'

Definition at line 44 of file createPayload.py.

string createPayload::workflowdirArchive = 'archive/'

Definition at line 47 of file createPayload.py.

string createPayload::workflowdirLastPayloads = 'lastPayloads/'

Definition at line 45 of file createPayload.py.

Definition at line 46 of file createPayload.py.

tuple createPayload::writedb_template = os.getenv("CMSSW_BASE")

Definition at line 281 of file createPayload.py.