8
8
localPilot = pilotWrapperScript(pilotFilesCompressedEncodedDict,
9
9
pilotOptions,
10
10
pilotExecDir)
11
- _writePilotWrapperFile(localPilot=localPilot)
11
+ _writePilotWrapperFile(localPilot=localPilot)
12
12
13
13
"""
14
- from __future__ import absolute_import
15
- from __future__ import division
16
- from __future__ import print_function
14
+ from __future__ import absolute_import , division , print_function
17
15
18
- import os
19
- import tempfile
20
16
import base64
21
17
import bz2
18
+ import os
19
+ import tempfile
22
20
23
21
pilotWrapperContent = """#!/bin/bash
24
22
if command -v python &> /dev/null; then
78
76
79
77
80
78
def pilotWrapperScript (
81
- pilotFilesCompressedEncodedDict = None , pilotOptions = "" , pilotExecDir = "" , envVariables = None , location = ""
79
+ pilotFilesCompressedEncodedDict = None ,
80
+ pilotOptions = "" ,
81
+ pilotExecDir = "" ,
82
+ envVariables = None ,
83
+ location = "" ,
84
+ CVMFS_locations = None ,
82
85
):
83
86
"""Returns the content of the pilot wrapper script.
84
87
@@ -95,6 +98,8 @@ def pilotWrapperScript(
95
98
:type envVariables: dict
96
99
:param location: location where to get the pilot files
97
100
:type location: string
101
+ :param CVMFS_locations: optional CVMFS locations of where to get the pilot files
102
+ :type CVMFS_locations: list
98
103
99
104
:returns: content of the pilot wrapper
100
105
:rtype: string
@@ -106,6 +111,20 @@ def pilotWrapperScript(
106
111
if envVariables is None :
107
112
envVariables = {}
108
113
114
+ if CVMFS_locations is None :
115
+ # What is in this location is almost certainly incorrect, especially the pilot.json
116
+ CVMFS_locs = '["file:/cvmfs/dirac.egi.eu/pilot"]'
117
+ else :
118
+ # Here we are making the assumption that, if CVMFS_locations is, e.g., ['/cvmfs/somewhere', '/cvmfs/elsewhere']
119
+ # and the project is 'LHCb',
120
+ # then the pilot can maybe be found at locations
121
+ # - file:/cvmfs/somewhere/lhcbdirac/pilot
122
+ # - file:/cvmfs/elsewhere/lhcbdirac/pilot
123
+ project = "dirac"
124
+ if "-l" in pilotOptions :
125
+ project = pilotOptions .split (" " )[pilotOptions .split (" " ).index ("-l" ) + 1 ].lower () + "dirac"
126
+ CVMFS_locs = "[" + "," .join ('"file:' + os .path .join (loc , project , 'pilot"' ) for loc in CVMFS_locations ) + "]"
127
+
109
128
compressedString = ""
110
129
# are there some pilot files to unpack? Then we create the unpacking string
111
130
for pfName , encodedPf in pilotFilesCompressedEncodedDict .items ():
@@ -178,8 +197,8 @@ def pilotWrapperScript(
178
197
# we try from the available locations
179
198
locs = [os.path.join('https://', loc) for loc in location]
180
199
locations = locs + [os.path.join(loc, 'pilot') for loc in locs]
181
- # adding also, as last the cvmfs location dirac.egi.eu, but this won't contain a valid JSON
182
- locations += ['file:/cvmfs/dirac.egi.eu/pilot/']
200
+ # adding also the cvmfs locations
201
+ locations += %(CVMFS_locs)s
183
202
184
203
for loc in locations:
185
204
print('Trying %%s' %% loc)
@@ -262,7 +281,8 @@ def pilotWrapperScript(
262
281
logger.debug('Checksum matched')
263
282
264
283
""" % {
265
- "location" : location
284
+ "location" : location ,
285
+ "CVMFS_locs" : CVMFS_locs ,
266
286
}
267
287
268
288
localPilot += (
0 commit comments