15 |
|
print 'echo "CMSSW_BASE not set"' |
16 |
|
sys.exit(-1) |
17 |
|
|
18 |
< |
shKind = 'sh' # fix for wrapper shell, temporary #'csh' #Fabio |
19 |
< |
if 'BASH' in os.environ: |
18 |
> |
# identify the shell kind |
19 |
> |
sout, sin, serr = popen2.popen3('echo $BASH') |
20 |
> |
l = sout.readlines()[0] |
21 |
> |
sout.close() |
22 |
> |
sin.close() |
23 |
> |
serr.close() |
24 |
> |
|
25 |
> |
if len(l)!=0: #'BASH' in os.environ: |
26 |
|
shKind = 'sh' |
27 |
+ |
else: |
28 |
+ |
shKind = 'csh' |
29 |
|
|
30 |
|
# -create -submit special case: first part # Fabio |
31 |
|
cachedPath = os.environ['PATH'] |
58 |
|
|
59 |
|
pre_env = {} |
60 |
|
drop_out_cmd = '' |
61 |
+ |
fakePath = '' # needed for source ordering in -create # Fabio |
62 |
+ |
|
63 |
|
for e in outl: |
64 |
< |
v = e.strip() |
65 |
< |
k = str(v.split(' ')[0]) |
66 |
< |
v = str(v.split(' ')[1].replace('"','')).split(':') |
64 |
> |
vl = e.strip() |
65 |
> |
k = str(vl.split(' ')[0]) |
66 |
> |
v = str(vl.split(' ')[1].replace('"','')).split(':') |
67 |
> |
|
68 |
> |
if k == 'PATH': |
69 |
> |
fakePath = vl.split(' ')[1].replace('"','') |
70 |
> |
|
71 |
|
if 'SCRAMRT' not in k: |
72 |
|
pre_env[k] = []+v |
73 |
|
else: |
114 |
|
# this value will be used by crab.py whenever both -create and -submit are used |
115 |
|
# |
116 |
|
if '-create' in sys.argv or '-publish' in sys.argv: |
117 |
+ |
# source order bug # Fabio |
118 |
+ |
# reproduce a PATH as lcg->cmssw would produce and compare it with the cachedPath |
119 |
+ |
# if they differs then override the cached path with the prepared one (brute force ordering) |
120 |
+ |
# |
121 |
+ |
fakePath = fakePath[:-len(':$SCRAMRT_PATH')] |
122 |
+ |
newPath = fakePath + cachedPath.replace(fakePath,'') |
123 |
+ |
if shKind == 'sh': |
124 |
+ |
print 'export PATH="%s";\n'%newPath |
125 |
+ |
else: |
126 |
+ |
print 'setenv PATH "%s";\n'%newPath |
127 |
+ |
|
128 |
|
# PATH |
129 |
|
purgedList = [ i for i in cachedPath.split(':') if i not in pre_env['PATH'] ] |
130 |
|
purgedList = purgedList + pre_env['PATH'] |