#!/bin/bash "exec" "python" "$0" "$@" """ Install Atlas SW Usage: $ installAthasSW [options] See the 'command-line parameters' section below for details of options """ # import optparse import re import os import sys import getopt import commands # error code EC_Fail = 40 ################################ # # command-line parameters gridname = 'OSG' release = '14.2.0' project = 'AtlasProduction' arch = '_i686_slc4_gcc34' reqtype = 'validation' resource = 'BNL_ATLAS_test0' cename = 'BNL_ATLAS_test0' sitename = 'BNL_ATLAS_test0' physpath = '/usatlas/OSG/pacball-test/atlas_app/atlas_rel/14.2.0' reltype = 'release' pacman = '3.26' pacball = 'AtlasProduction_14_2_0_i686_slc4_gcc34_opt.time-2008-07-01-09-05-23.md5-3de8832f86c95353b0b3f07693d3e694.sh' pacballrepo = 'http://classis01.roma1.infn.it/pacballs/download.php?file=' diskfree = '9000000:20000:3000000' jobinfo = '14.2.0-validation.xml' tag = 'VO-atlas-AtlasProduction-14.2.0-i686-slc4-gcc34' requires = '' dbrelease = '' longoptnames = ["gridname=", "release=", "project=", "arch=", "reqtype=", "resource=", "cename=", "sitename=", "physpath=", "reltype=", "pacman=", "pacball=", "pacballrepo=", "diskfree=", "jobinfo=", "tag=", "requires=", "dbrelease=", ] ################################ # parse commands-line parameters opts, args = getopt.getopt(sys.argv[1:],'',longoptnames) for o, a in opts: # remove -- optName = re.sub('^--','',o) # assign execStr = '%s=a' % optName exec execStr # pack parameters to a map varMap = {} print "==== Parameters ====" for longOpt in longoptnames: # remove = optName = re.sub('=$','',longOpt) # get value execStr = 'varMap["%s"] = %s' % (longOpt,optName) exec execStr # dump print '%12s : %s' % (optName,varMap[longOpt]) # construct XML xmlName = 'installdef.xml' xmlFile = open(xmlName,'w') # write header xmlFile.write(""" """) for longOpt in longoptnames: # skip empty values if varMap[longOpt] == '': continue # remove = optName = re.sub('=$','',longOpt) # write body xmlFile.write(' <%s>%s\n' % (optName,varMap[longOpt],optName)) # write trailer xmlFile.write(""" """) xmlFile.close() print "\n==== %s ====" % xmlName print commands.getoutput('cat %s' % xmlName) # get scripts print "\n==== Get scripts ====" httpDir = 'http://www.usatlas.bnl.gov/svn/panda/apps/sw/' scripts = ['sw-mgr','ljsfwsc.py','osg_example.py'] for script in scripts: com = 'wget %s%s' % (httpDir,script) status,output = commands.getstatusoutput(com) print output print status status %= 255 if status != 0: "ERROR : cloud not get %s" % script sys.exit(EC_Fail) # chmod os.chmod(script,0755) # run print "\n==== Start osg_example ====" com = 'python osg_example.py' status = os.system(com) status %= 255 print "==== End with %s ====" % status if status != 0: "ERROR : failed to run %s" % com sys.exit(status)