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