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
50 def run( self, options ):
53 theCrab.initialize_( options )
55 except crab_exceptions.CrabException
as e:
60 if __name__ ==
"__main__":
62 theCrabOptions = {
"-create":
"",
63 "-cfg":
"TkAlOfflineValidation.shiftPlots.crab.cfg"}
64 theCrab.run( theCrabOptions )
66 theCrabOptions = {
"-submit":
""}
67 theCrab.run( theCrabOptions )
69 theCrabOptions = {
"-status":
""}
70 theCrab.run( theCrabOptions )
72 theCrabOptions = {
"-getoutput":
""}
74 theCrab.run( theCrabOptions )
75 except AllInOneError
as e:
static std::string join(char **cmd)