4 from TkAlExceptions
import AllInOneError
7 crabSourceScript =
'/afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh'
10 sourceStr = (
'cd $CMSSW_BASE/src;'
11 'source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh;'
12 'eval `scramv1 runtime -sh`;'
13 'source ' + crabSourceScript +
' && env' )
14 sourceCmd = [
'bash',
'-c', sourceStr ]
15 sourceProc = subprocess.Popen(sourceCmd, stdout = subprocess.PIPE)
16 for line
in sourceProc.stdout:
17 (key, _, value) = line.partition(
"=")
18 os.environ[key] = value.replace(
"\n",
"")
19 sourceProc.communicate()
22 crabFile = open(
'/'.
join([os.environ[
"CRABPYTHON"],
'crab']))
23 theLines = crabFile.readlines()
26 if ( line[0] ==
'#' )
or \
27 ( line ==
' python $CRABPYTHON/crab.py $*\n' ):
29 theLine.append( line )
30 tempFilePath =
"tempCrab"
31 tempFile = open( tempFilePath,
"w" )
32 tempFile.write(
''.
join(theLine) )
34 crabStr = (
'source tempCrab && env' )
35 crabCmd = [
'bash',
'-c', crabStr ]
36 crabProc = subprocess.Popen(crabCmd, stdout = subprocess.PIPE)
37 for line
in crabProc.stdout:
38 (key, _, value) = line.partition(
"=")
39 os.environ[key] = value.replace(
"\n",
"")
40 crabProc.communicate()
41 os.remove( tempFilePath )
44 sys.path.extend( os.environ[
"PYTHONPATH"].
split(
':' ) )
47 import crab_exceptions
53 def run( self, options ):
56 theCrab.initialize_( options )
58 except crab_exceptions.CrabException, e:
63 if __name__ ==
"__main__":
65 theCrabOptions = {
"-create":
"",
66 "-cfg":
"TkAlOfflineValidation.shiftPlots.crab.cfg"}
67 theCrab.run( theCrabOptions )
69 theCrabOptions = {
"-submit":
""}
70 theCrab.run( theCrabOptions )
72 theCrabOptions = {
"-status":
""}
73 theCrab.run( theCrabOptions )
75 theCrabOptions = {
"-getoutput":
""}
77 theCrab.run( theCrabOptions )
78 except AllInOneError, e:
static std::string join(char **cmd)