1 from __future__
import print_function
5 from TkAlExceptions
import AllInOneError
8 crabSourceScript =
'/afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh' 11 sourceStr = (
'cd $CMSSW_BASE/src;' 12 'source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh;' 13 'eval `scramv1 runtime -sh`;' 14 'source ' + crabSourceScript +
' && env' )
15 sourceCmd = [
'bash',
'-c', sourceStr ]
16 sourceProc = subprocess.Popen(sourceCmd, stdout = subprocess.PIPE)
17 for line
in sourceProc.stdout:
18 (key, _, value) = line.partition(
"=")
19 os.environ[key] = value.replace(
"\n",
"")
20 sourceProc.communicate()
23 crabFile = open(
'/'.
join([os.environ[
"CRABPYTHON"],
'crab']))
24 theLines = crabFile.readlines()
27 if ( line[0] ==
'#' )
or \
28 ( line ==
' python $CRABPYTHON/crab.py $*\n' ):
30 theLine.append( line )
31 tempFilePath =
"tempCrab" 32 tempFile = open( tempFilePath,
"w" )
33 tempFile.write(
''.
join(theLine) )
35 crabStr = (
'source tempCrab && env' )
36 crabCmd = [
'bash',
'-c', crabStr ]
37 crabProc = subprocess.Popen(crabCmd, stdout = subprocess.PIPE)
38 for line
in crabProc.stdout:
39 (key, _, value) = line.partition(
"=")
40 os.environ[key] = value.replace(
"\n",
"")
41 crabProc.communicate()
42 os.remove( tempFilePath )
45 sys.path.extend( os.environ[
"PYTHONPATH"].
split(
':' ) )
48 import crab_exceptions
51 def run( self, options ):
54 theCrab.initialize_( options )
56 except crab_exceptions.CrabException
as e:
61 if __name__ ==
"__main__":
63 theCrabOptions = {
"-create":
"",
64 "-cfg":
"TkAlOfflineValidation.shiftPlots.crab.cfg"}
65 theCrab.run( theCrabOptions )
67 theCrabOptions = {
"-submit":
""}
68 theCrab.run( theCrabOptions )
70 theCrabOptions = {
"-status":
""}
71 theCrab.run( theCrabOptions )
73 theCrabOptions = {
"-getoutput":
""}
75 theCrab.run( theCrabOptions )
76 except AllInOneError
as e:
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)