Exemple #1
0
def __cmd_setup_env__(workDir, rootVer):

    # create cmt dir to setup Athena
    setupEnv = ''

    if useAthenaPackages:
        if not useCMake:
            tmpDir = '%s/%s/cmt' % (workDir, str(uuid.uuid4()))
            print("Making tmpDir", tmpDir)
            os.makedirs(tmpDir)
            # create requirements
            oFile = open(tmpDir + '/requirements', 'w')
            oFile.write('use AtlasPolicy AtlasPolicy-*\n')
            oFile.write('use PathResolver PathResolver-* Tools\n')
            oFile.close()
            # setup command
            setupEnv = 'export CMTPATH=%s:$CMTPATH; ' % workDir
            setupEnv += 'cd %s; cat requirements; cmt config; source ./setup.sh; cd -; ' % tmpDir
        else:
            cmakeSetupDir = 'usr/*/*/InstallArea/*'
            print("CMake setup dir : {0}".format(cmakeSetupDir))
            if len(glob.glob(cmakeSetupDir)) > 0:
                setupEnv = 'source {0}/setup.sh;'.format(cmakeSetupDir)
            else:
                print('WARNING: CMake setup dir not found')
                setupEnv = ''

    # setup root
    if rootVer != '':
        rootBinDir = workDir + '/pandaRootBin'
        # use CVMFS if setup script is available
        if os.path.exists('%s/pandaUseCvmfSetup.sh' % rootBinDir):
            iFile = open('%s/pandaUseCvmfSetup.sh' % rootBinDir)
            setupEnv += iFile.read()
            iFile.close()
            setupEnv += ' root.exe -q;'
        else:
            setupEnv += ' export ROOTSYS=%s/root; export PATH=$ROOTSYS/bin:$PATH; export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH; export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH; root.exe -q; ' % rootBinDir

    # RootCore
    if useRootCore:
        pandaRootCoreWD = os.path.abspath(runDir + '/__panda_rootCoreWorkDir')
        if os.path.exists('%s/RootCore/scripts/grid_run.sh' % pandaRootCoreWD):
            setupEnv += 'source %s/RootCore/scripts/grid_run.sh %s; ' % (
                pandaRootCoreWD, pandaRootCoreWD)

    # TestArea
    setupEnv += "export TestArea=%s; " % workDir

    print("=== setup command ===")
    print(setupEnv)
    print('')
    print("=== env ===")
    print(commands_get_status_output(setupEnv + 'env')[-1])

    return setupEnv
Exemple #2
0
def __exec__(cmd, mergelog=False):
    '''
    wrapper of making system call
    '''
    print('dir : %s' % os.getcwd())
    print('exec: %s' % cmd)
    s, o = commands_get_status_output(cmd)
    print('status: %s' % (s % 255))
    print('stdout:\n%s' % o)
    return s, o
Exemple #3
0
 def make(self, verbose=False):
     print ("\n===== make PandaTracer =====")
     # create lib base dir
     if self.debugFlag:
         self.libBaseDir = os.getcwd()
     else:
         self.libBaseDir = os.getcwd() + '/' + str(uuid.uuid4())
         commands_get_status_output('rm -rf %s' % self.libBaseDir)
         os.makedirs(self.libBaseDir)
     # set output filename
     self.logName = self.libBaseDir + '/pandatracerlog.txt'
     outH = open('outfilename.h','w')
     outH.write('const char *pandatracer_outfilename = "%s";\n' % self.logName)
     outH.write("const char *pandatracer_sofilename = \"%s/$LIB/%s.so\";\n" % \
                (self.libBaseDir,self.wrapperName))
     outH.close()
     # make lib and lib64
     for arcStr, archOpt, archLib in self.archOptMap:
         print("  {0} making with opt={1} in {2}".format(arcStr, archOpt, archLib))
         if archOpt:
             step_base = 'gcc {0} '.format(archOpt)
         else:
             step_base = 'gcc '
         step1 = step_base + '-I. -fPIC -c -Wall %s/%s.c -o %s.o' % \
                 (modFullPath, self.wrapperName, self.wrapperName)
         step2 = step_base + '-shared %s.o -ldl -lstdc++ -o %s/%s/%s.so' % \
                 (self.wrapperName,self.libBaseDir,archLib,self.wrapperName)
         step_d = step_base + '-shared -fpic -o %s/%s/%s.so -xc /dev/null ' % \
                 (self.libBaseDir,archLib,self.wrapperName)
         # makedir
         try:
             os.makedirs(self.libBaseDir+'/'+archLib)
         except:
             pass
         isFailed = False
         # make
         if verbose:
             print("    com for make: {0}".format(step1))
         p = subprocess.Popen(step1.split(), stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
         out, err = p.communicate()
         if p.returncode != 0:
             if verbose:
                 print ("    failed with {0}".format(err))
             isFailed = True
         else:
             if verbose:
                 print("    com for so: {0}".format(step2))
             p = subprocess.Popen(step2.split(), stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             out, err = p.communicate()
             if p.returncode != 0:
                 if verbose:
                     print("    failed with {0}".format(err))
                 isFailed = True
         # make dummy if failed
         if isFailed:
             if verbose:
                 print("    com for dummy: {0}".format(step_d))
             p = subprocess.Popen(step_d.split(), stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             out, err = p.communicate()
             if p.returncode != 0:
                 if verbose:
                     print("    failed with {0}".format(err))
                 print ("  %s is not supported" % arcStr)
             else:
                 print ("  %s uses dummy" % arcStr)
         else:
             print ("  %s succeeded" % arcStr)
         if verbose:
             print("")
     # log name
     commands_get_status_output('touch %s' % self.getLogName())
     print ("Log location -> %s" % self.getLogName())
     # return
     return
    sys.exit(EC_MissingArg)

# save current dir
currentDir = record_exec_directory()

print(time.ctime())

url = '%s/cache/%s' % (sourceURL, sources)
tmpStat, tmpOut = get_file_via_http(full_url=url)
if not tmpStat:
    print("ERROR : " + tmpOut)
    sys.exit(EC_NoTarball)

# goto work dir
workDir = currentDir + '/workDir'
print(commands_get_status_output('rm -rf %s' % workDir)[-1])
os.makedirs(workDir)
print("--- Goto workDir %s ---\n" % workDir)
os.chdir(workDir)

# cmake
if useCMake:
    # go back to current dir
    os.chdir(currentDir)
    print("--- Checking tarball for CMake ---\n")
    os.rename(sources, libraries)
    if debugFlag:
        # expand
        tmpStat = subprocess.call('tar xvfzm {0}'.format(libraries),
                                  shell=True)
    else:
Exemple #5
0
    print("execWithRealFileNames", execWithRealFileNames)
    print("===================")
except Exception as e:
    print('ERROR: missing parameters : %s' % str(e))
    sys.exit(EC_MissingArg)

# save current dir
currentDir = record_exec_directory()
currentDirFiles = os.listdir('.')

# work dir
workDir = currentDir + "/workDir"

# create work dir
if not postprocess:
    commands_get_status_output('rm -rf %s' % workDir)
    os.makedirs(workDir)

    # collect GUIDs from PoolFileCatalog
    directTmpTurl = {}
    try:
        print("===== PFC from pilot =====")
        tmpPcFile = open("PoolFileCatalog.xml")
        print(tmpPcFile.read())
        tmpPcFile.close()
        # parse XML
        root = xml.dom.minidom.parse("PoolFileCatalog.xml")
        files = root.getElementsByTagName('File')
        for file in files:
            # get ID
            id = str(file.getAttribute('ID'))
Exemple #6
0
        shutil.rmtree(workDir, ignore_errors=True)
        os.makedirs(workDir)
    os.chdir(workDir)

    if not postprocess:
        ## expand library tarballs
        libs = []
        libs.append(libTgz)
        libs.append(libraries)
        libs.append(archiveJobO)

        for lib in libs:
            if lib == '':
                pass
            elif lib.startswith('/'):
                print(commands_get_status_output('tar xvfzm %s' % lib)[-1])
            else:
                print(
                    commands_get_status_output('tar xvfzm %s/%s' %
                                               (currentDir, lib))[-1])

        ## compose athena/root environment setup command
        cmdEnvSetup = __cmd_setup_env__(workDir, rootVer)

        ## create and change to rundir
        commands_get_status_output('mkdir -p %s' % runDir)
    os.chdir(runDir)

    # make dump file for preprocess
    dumpFileName = os.path.join(currentDir, '__run_main_exec.sh')
    dumpFile = None
Exemple #7
0
# parse options
options, args = optP.parse_args()
if options.verbose:
    tmpLog.debug("=== parameters ===")
    print(options)
    print('')

# save current dir
currentDir = os.getcwd()
currentDirFiles = os.listdir('.')
tmpLog.info("Running in %s " % currentDir)

# crate work dir
workDir = currentDir + "/workDir"
commands_get_status_output('rm -rf %s' % workDir)
os.makedirs(workDir)
os.chdir(workDir)

# get run/event list
url = '%s/cache/%s.gz' % (options.sourceURL, options.goodRunListXML)
tmpLog.info("getting GRL from %s" % url)

tmpStatus, tmpOut = get_file_via_http(full_url=url)
if not tmpStatus:
    tmpLog.error(tmpOut)
    sys.exit(EC_WGET)
print(commands_get_status_output('gunzip %s.gz' % options.goodRunListXML)[-1])

# convert run/evt list to dataset/LFN list
try:
Exemple #8
0
# save current dir
currentDir = record_exec_directory()

print ("--- wget ---")
print (time.ctime())


# compile Athena packages
if useAthenaPackages and not noCompile:
    # get TRF
    trfName    = 'buildJob-00-00-03'
    trfBaseURL = 'http://pandaserver.cern.ch:25080/trf/user/'
    url = trfBaseURL+trfName
    get_file_via_http(full_url=url)
    # execute
    commands_get_status_output('chmod +x %s' % trfName)
    if useCMake:
        tmpLibName = libraries
    else:
        tmpLibName = 'tmplib.%s' % str(uuid.uuid4())
    com = "./%s -i %s -o %s --debug --sourceURL %s " % (trfName,sources,tmpLibName,sourceURL)
    if useCMake:
        com += '--useCMake '
    print ("--- Compile Athena packages ---")
    print (time.ctime())
    print (com)
    if debugFlag:
        status = os.system(com)
    else:
        status,output = commands_get_status_output(com)
        print (output)
Exemple #9
0
# work dir
workDir = currentDir + "/workDir"

# for input
directTmpTurl = {}
directPFNs = {}
if not postprocess and not coprocess:
    # check loop count
    if maxLoopCount and iterationCount:
        if maxLoopCount <= int(iterationCount):
            print(
                "INFO : exit since loop count PILOT_EXEC_ITERATION_COUNT={} reached the limit"
                .format(iterationCount))
            sys.exit(EC_MAXLOOP)
    # create work dir
    commands_get_status_output('rm -rf %s' % workDir)
    os.makedirs(workDir)

    # collect GUIDs from PoolFileCatalog
    try:
        print("\n===== PFC from pilot =====")
        tmpPcFile = open("PoolFileCatalog.xml")
        print(tmpPcFile.read())
        tmpPcFile.close()
        # parse XML
        root = xml.dom.minidom.parse("PoolFileCatalog.xml")
        files = root.getElementsByTagName('File')
        for file in files:
            # get ID
            id = str(file.getAttribute('ID'))
            # get PFN node
Exemple #10
0
 def make(self):
     print("\n===== make PandaTracer =====")
     # create lib base dir
     if self.debugFlag:
         self.libBaseDir = os.getcwd()
     else:
         self.libBaseDir = os.getcwd() + '/' + str(uuid.uuid4())
         commands_get_status_output('rm -rf %s' % self.libBaseDir)
         os.makedirs(self.libBaseDir)
     # set output filename
     self.logName = self.libBaseDir + '/pandatracerlog.txt'
     outH = open('outfilename.h', 'w')
     outH.write('const char *pandatracer_outfilename = "%s";\n' %
                self.logName)
     outH.write("const char *pandatracer_sofilename = \"%s/$LIB/%s.so\";\n" % \
                (self.libBaseDir,self.wrapperName))
     outH.close()
     # make lib and lib64
     for archOpt in self.archOptMap:
         archLib = self.archOptMap[archOpt]
         step1 = 'gcc -%s -I. -fPIC -c -Wall %s/%s.c -o %s.o' % \
                 (archOpt,modFullPath,self.wrapperName,self.wrapperName)
         step2 = 'gcc -%s -shared %s.o -ldl -lstdc++ -o %s/%s/%s.so' % \
                 (archOpt,self.wrapperName,self.libBaseDir,archLib,self.wrapperName)
         stepd = 'gcc -shared -fpic -o %s/%s/%s.so -xc /dev/null -%s' % \
                 (self.libBaseDir,archLib,self.wrapperName,archOpt)
         # makedir
         try:
             os.makedirs(self.libBaseDir + '/' + archLib)
         except:
             pass
         isFailed = False
         # make
         p = subprocess.Popen(step1.split(),
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         out, err = p.communicate()
         if p.returncode != 0:
             #print (" com : {0} failed with {1}".format(step1, err))
             isFailed = True
         else:
             p = subprocess.Popen(step2.split(),
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             out, err = p.communicate()
             if p.returncode != 0:
                 #print (" com : {0} failed with {1}".format(step2, err))
                 isFailed = True
         # make dummy if failed
         if isFailed:
             #print ("  %s failed" % archOpt)
             p = subprocess.Popen(stepd.split(),
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             out, err = p.communicate()
             if p.returncode != 0:
                 #print (" com : {0} failed with {1}".format(stepd, err))
                 print("  %s is not supported" % archOpt)
             else:
                 print("  %s uses dummy" % archOpt)
         else:
             print("  %s succeeded" % archOpt)
     # log name
     commands_get_status_output('touch %s' % self.getLogName())
     print("Log location -> %s" % self.getLogName())
     # return
     return
Exemple #11
0
if flagMinBias:
    print("=== New minbiasFiles ===")
    print(minbiasFiles)
if flagCavern:
    print("=== New cavernFiles ===")
    print(cavernFiles)
if flagBeamHalo:
    print("=== New beamHaloFiles ===")
    print(beamHaloFiles)
if flagBeamGas:
    print("=== New beamGasFiles ===")
    print(beamGasFiles)

# crate work dir
workDir = currentDir + "/workDir"
commands_get_status_output('rm -rf %s' % workDir)
os.makedirs(workDir)
os.chdir(workDir)

# expand libraries
if libraries == '':
    tmpStat, tmpOut = 0, ''
elif libraries.startswith('/'):
    tmpStat, tmpOut = commands_get_status_output('tar xvfzm %s' % libraries)
    print(tmpOut)
else:
    tmpStat, tmpOut = commands_get_status_output('tar xvfzm %s/%s' %
                                                 (currentDir, libraries))
    print(tmpOut)
if tmpStat != 0:
    print("ERROR : {0} is corrupted".format(libraries))