ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerEdg.py
Revision: 1.79
Committed: Wed Aug 16 16:49:51 2006 UTC (18 years, 8 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD_20092006
Changes since 1.78: +13 -3 lines
Log Message:
support VOMS role and use VO as defined in crab.cfg

File Contents

# User Rev Content
1 nsmirnov 1.1 from Scheduler import Scheduler
2     from crab_logger import Logger
3     from crab_exceptions import *
4     from crab_util import *
5 slacapra 1.50 from EdgConfig import *
6 nsmirnov 1.1 import common
7    
8 slacapra 1.18 import os, sys, time
9 nsmirnov 1.1
10     class SchedulerEdg(Scheduler):
11     def __init__(self):
12     Scheduler.__init__(self,"EDG")
13 slacapra 1.8 self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \
14     "children_hist","children_num","children_states","condorId","condor_jdl", \
15     "cpuTime","destination", "done_code","exit_code","expectFrom", \
16     "expectUpdate","globusId","jdl","jobId","jobtype", \
17     "lastUpdateTime","localId","location", "matched_jdl","network_server", \
18     "owner","parent_job", "reason","resubmitted","rsl","seed",\
19     "stateEnterTime","stateEnterTimes","subjob_failed", \
20     "user tags" , "status" , "status_code","hierarchy"]
21 nsmirnov 1.1 return
22    
23     def configure(self, cfg_params):
24 spiga 1.49
25 slacapra 1.46 try:
26     RB = cfg_params["EDG.rb"]
27     edgConfig = EdgConfig(RB)
28     self.edg_config = edgConfig.config()
29     self.edg_config_vo = edgConfig.configVO()
30     except KeyError:
31     self.edg_config = ''
32     self.edg_config_vo = ''
33 nsmirnov 1.1
34 slacapra 1.51 try:
35     self.proxyServer = cfg_params["EDG.proxy_server"]
36     except KeyError:
37     self.proxyServer = 'myproxy.cern.ch'
38     common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
39 spiga 1.49
40 slacapra 1.79 try:
41     self.role = cfg_params["EDG.rb"]
42     except KeyError:
43     self.role = None
44    
45     try:
46     self.role = cfg_params["EDG.role"]
47     except KeyError:
48     self.role = None
49    
50 nsmirnov 1.1 try: self.LCG_version = cfg_params["EDG.lcg_version"]
51     except KeyError: self.LCG_version = '2'
52    
53     try: self.EDG_requirements = cfg_params['EDG.requirements']
54     except KeyError: self.EDG_requirements = ''
55    
56 spiga 1.49 try: self.EDG_retry_count = cfg_params['EDG.retry_count']
57 nsmirnov 1.1 except KeyError: self.EDG_retry_count = ''
58    
59 fanzago 1.48 try:
60     self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
61     #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
62     except KeyError:
63     self.EDG_ce_black_list = ''
64    
65     try:
66     self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
67     #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
68     except KeyError: self.EDG_ce_white_list = ''
69    
70 fanzago 1.14 try: self.VO = cfg_params['EDG.virtual_organization']
71     except KeyError: self.VO = 'cms'
72    
73 spiga 1.49 try: self.return_data = cfg_params['USER.return_data']
74     except KeyError: self.return_data = 1
75    
76 fanzago 1.39 try:
77     self.copy_input_data = common.analisys_common_info['copy_input_data']
78 fanzago 1.41 #print "self.copy_input_data = ", self.copy_input_data
79 fanzago 1.39 except KeyError: self.copy_input_data = 0
80    
81 fanzago 1.14 try:
82     self.copy_data = cfg_params["USER.copy_data"]
83 fanzago 1.30 if int(self.copy_data) == 1:
84     try:
85     self.SE = cfg_params['USER.storage_element']
86     self.SE_PATH = cfg_params['USER.storage_path']
87     except KeyError:
88     msg = "Error. The [USER] section does not have 'storage_element'"
89     msg = msg + " and/or 'storage_path' entries, necessary to copy the output"
90     common.logger.message(msg)
91     raise CrabException(msg)
92     except KeyError: self.copy_data = 0
93    
94     if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ):
95     msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n'
96     msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n'
97     raise CrabException(msg)
98 fanzago 1.38
99     try:
100     self.lfc_host = cfg_params['EDG.lfc_host']
101     except KeyError:
102     msg = "Error. The [EDG] section does not have 'lfc_host' value"
103     msg = msg + " it's necessary to know the LFC host name"
104     common.logger.message(msg)
105     raise CrabException(msg)
106     try:
107     self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type']
108     except KeyError:
109     msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value"
110     msg = msg + " it's necessary to know the catalog type"
111     common.logger.message(msg)
112     raise CrabException(msg)
113     try:
114     self.lfc_home = cfg_params['EDG.lfc_home']
115     except KeyError:
116     msg = "Error. The [EDG] section does not have 'lfc_home' value"
117     msg = msg + " it's necessary to know the home catalog dir"
118     common.logger.message(msg)
119     raise CrabException(msg)
120 fanzago 1.30
121 fanzago 1.14 try:
122     self.register_data = cfg_params["USER.register_data"]
123 fanzago 1.30 if int(self.register_data) == 1:
124     try:
125     self.LFN = cfg_params['USER.lfn_dir']
126     except KeyError:
127     msg = "Error. The [USER] section does not have 'lfn_dir' value"
128 fanzago 1.36 msg = msg + " it's necessary for LCF registration"
129 fanzago 1.30 common.logger.message(msg)
130     raise CrabException(msg)
131     except KeyError: self.register_data = 0
132    
133     if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ):
134     msg = 'Warning: register_data = 1 must be used with copy_data = 1\n'
135     msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
136     common.logger.message(msg)
137     raise CrabException(msg)
138 fanzago 1.14
139     try: self.EDG_requirements = cfg_params['EDG.requirements']
140     except KeyError: self.EDG_requirements = ''
141    
142     try: self.EDG_retry_count = cfg_params['EDG.retry_count']
143     except KeyError: self.EDG_retry_count = ''
144    
145     try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time']
146     except KeyError: self.EDG_clock_time= ''
147    
148     try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
149     except KeyError: self.EDG_cpu_time = ''
150    
151 fanzago 1.16 # Add EDG_WL_LOCATION to the python path
152    
153     try:
154     path = os.environ['EDG_WL_LOCATION']
155     except:
156     msg = "Error: the EDG_WL_LOCATION variable is not set."
157     raise CrabException(msg)
158    
159     libPath=os.path.join(path, "lib")
160     sys.path.append(libPath)
161     libPath=os.path.join(path, "lib", "python")
162     sys.path.append(libPath)
163 nsmirnov 1.1
164 slacapra 1.18 self.proxyValid=0
165 gutsche 1.60
166 slacapra 1.61 try:
167     self._taskId = cfg_params['taskId']
168     except:
169     self._taskId = ''
170 gutsche 1.60
171 nsmirnov 1.1 return
172    
173 fanzago 1.10
174     def sched_parameter(self):
175     """
176     Returns file with scheduler-specific parameters
177     """
178    
179     if (self.edg_config and self.edg_config_vo != ''):
180     self.param='sched_param.clad'
181     param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
182     param_file.write('RBconfig = "'+self.edg_config+'";\n')
183     param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
184     param_file.close()
185     return 1
186     else:
187     return 0
188 fanzago 1.13
189 nsmirnov 1.2 def wsSetupEnvironment(self):
190     """
191     Returns part of a job script which does scheduler-specific work.
192     """
193 spiga 1.49 txt = ''
194 mkirn 1.75 txt += '# strip arguments\n'
195     txt += 'echo "strip arguments"\n'
196     txt += 'args=("$@")\n'
197     txt += 'nargs=$#\n'
198     txt += 'shift $nargs\n'
199 gutsche 1.60 txt += "# job number (first parameter for job wrapper)\n"
200 mkirn 1.75 #txt += "NJob=$1\n"
201     txt += "NJob=${args[0]}\n"
202 gutsche 1.60
203     txt += '# job identification to DashBoard \n'
204 gutsche 1.64 txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
205     txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
206     txt += 'MonitorID=`echo ' + self._taskId + '`\n'
207     txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
208     txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
209     txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
210 gutsche 1.60
211 spiga 1.49 txt += 'echo "middleware discovery " \n'
212 gutsche 1.60 txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
213 spiga 1.49 txt += ' middleware=LCG \n'
214 gutsche 1.60 txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
215     txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
216 spiga 1.49 txt += ' echo "middleware =$middleware" \n'
217     txt += 'elif [ $GRID3_APP_DIR ]; then\n'
218     txt += ' middleware=OSG \n'
219 gutsche 1.60 txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
220     txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
221 spiga 1.49 txt += ' echo "middleware =$middleware" \n'
222     txt += 'elif [ $OSG_APP ]; then \n'
223     txt += ' middleware=OSG \n'
224 gutsche 1.60 txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
225     txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
226 spiga 1.49 txt += ' echo "middleware =$middleware" \n'
227     txt += 'else \n'
228 gutsche 1.60 txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
229     txt += ' echo "JOB_EXIT_STATUS = 10030" \n'
230     txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
231     txt += ' dumpStatus $RUNTIME_AREA/$repo \n'
232 gutsche 1.64 txt += ' rm -f $RUNTIME_AREA/$repo \n'
233     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
234     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
235 gutsche 1.60 txt += ' exit 1 \n'
236     txt += 'fi \n'
237    
238     txt += '# report first time to DashBoard \n'
239     txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
240 gutsche 1.64 txt += 'rm -f $RUNTIME_AREA/$repo \n'
241     txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
242     txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
243    
244 spiga 1.49 txt += '\n\n'
245    
246 fanzago 1.30 if int(self.copy_data) == 1:
247 fanzago 1.14 if self.SE:
248     txt += 'export SE='+self.SE+'\n'
249 fanzago 1.15 txt += 'echo "SE = $SE"\n'
250 fanzago 1.14 if self.SE_PATH:
251     if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
252     txt += 'export SE_PATH='+self.SE_PATH+'\n'
253 fanzago 1.15 txt += 'echo "SE_PATH = $SE_PATH"\n'
254 spiga 1.49
255 fanzago 1.38 txt += 'export VO='+self.VO+'\n'
256     ### FEDE: add some line for LFC catalog setting
257 spiga 1.49 txt += 'if [ $middleware == LCG ]; then \n'
258     txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
259     txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
260     txt += ' fi\n'
261     txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
262     txt += ' export LFC_HOST='+self.lfc_host+'\n'
263     txt += ' fi\n'
264     txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
265     txt += ' export LFC_HOME='+self.lfc_home+'\n'
266     txt += ' fi\n'
267     txt += 'elif [ $middleware == OSG ]; then\n'
268     txt += ' echo "LFC catalog setting to be implemented for OSG"\n'
269 fanzago 1.38 txt += 'fi\n'
270     #####
271 fanzago 1.30 if int(self.register_data) == 1:
272 spiga 1.49 txt += 'if [ $middleware == LCG ]; then \n'
273     txt += ' export LFN='+self.LFN+'\n'
274     txt += ' lfc-ls $LFN\n'
275     txt += ' result=$?\n'
276     txt += ' echo $result\n'
277 fanzago 1.36 ### creation of LFN dir in LFC catalog, under /grid/cms dir
278 spiga 1.49 txt += ' if [ $result != 0 ]; then\n'
279     txt += ' lfc-mkdir $LFN\n'
280     txt += ' result=$?\n'
281     txt += ' echo $result\n'
282     txt += ' fi\n'
283     txt += 'elif [ $middleware == OSG ]; then\n'
284     txt += ' echo " Files registration to be implemented for OSG"\n'
285 fanzago 1.36 txt += 'fi\n'
286     txt += '\n'
287 spiga 1.49
288     if self.VO:
289     txt += 'export VO='+self.VO+'\n'
290     if self.LFN:
291     txt += 'if [ $middleware == LCG ]; then \n'
292     txt += ' export LFN='+self.LFN+'\n'
293     txt += 'fi\n'
294     txt += '\n'
295    
296     txt += 'if [ $middleware == LCG ]; then\n'
297     txt += ' CloseCEs=`edg-brokerinfo getCE`\n'
298     txt += ' echo "CloseCEs = $CloseCEs"\n'
299     txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
300     txt += ' echo "CE = $CE"\n'
301     txt += 'elif [ $middleware == OSG ]; then \n'
302     txt += ' if [ $OSG_JOB_CONTACT ]; then \n'
303 mkirn 1.76 # txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
304     txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print ${args[0]}}\'` \n'
305 spiga 1.49 txt += ' else \n'
306 gutsche 1.60 txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
307     txt += ' echo "JOB_EXIT_STATUS = 10099" \n'
308     txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
309     txt += ' dumpStatus $RUNTIME_AREA/$repo \n'
310 gutsche 1.64 txt += ' rm -f $RUNTIME_AREA/$repo \n'
311     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
312     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
313 spiga 1.49 txt += ' exit 1 \n'
314     txt += ' fi \n'
315     txt += 'fi \n'
316    
317 nsmirnov 1.2 return txt
318 fanzago 1.15
319 fanzago 1.39 def wsCopyInput(self):
320     """
321     Copy input data from SE to WN
322     """
323     txt = ''
324     try:
325     self.copy_input_data = common.analisys_common_info['copy_input_data']
326     #print "self.copy_input_data = ", self.copy_input_data
327     except KeyError: self.copy_input_data = 0
328     if int(self.copy_input_data) == 1:
329 spiga 1.49 ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
330     txt += 'if [ $middleware == OSG ]; then\n'
331     txt += ' #\n'
332     txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n'
333     txt += ' #\n'
334     txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
335     txt += 'elif [ $middleware == LCG ]; then \n'
336     txt += ' #\n'
337     txt += ' # Copy Input Data from SE to this WN\n'
338     txt += ' #\n'
339 spiga 1.42 ### changed by georgia (put a loop copying more than one input files per jobs)
340 spiga 1.49 txt += ' for input_file in $cur_file_list \n'
341     txt += ' do \n'
342 fanzago 1.68 #### FEDE
343     #txt += ' echo "which lcg-cp" \n'
344     #txt += ' which lcg-cp \n'
345     #########
346 fanzago 1.70 txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
347 fanzago 1.68 txt += ' copy_input_exit_status=$?\n'
348     txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
349     txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n'
350     txt += ' echo "Problems with copying to WN" \n'
351     txt += ' else \n'
352     txt += ' echo "input copied into WN" \n'
353     txt += ' fi \n'
354 spiga 1.49 txt += ' done \n'
355 spiga 1.43 ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
356 spiga 1.49 txt += ' for file in $cur_pu_list \n'
357     txt += ' do \n'
358 fanzago 1.68 #### FEDE
359     #txt += ' echo "which lcg-cp" \n'
360     #txt += ' which lcg-cp \n'
361     #########
362 fanzago 1.70 txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
363 fanzago 1.72 txt += ' copy_input_pu_exit_status=$?\n'
364 fanzago 1.68 txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
365     txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
366     txt += ' echo "Problems with copying pu to WN" \n'
367     txt += ' else \n'
368     txt += ' echo "input pu files copied into WN" \n'
369     txt += ' fi \n'
370 spiga 1.49 txt += ' done \n'
371     txt += ' \n'
372     txt += ' ### Check SCRATCH space available on WN : \n'
373     txt += ' df -h \n'
374     txt += 'fi \n'
375    
376 fanzago 1.39 return txt
377    
378 fanzago 1.14 def wsCopyOutput(self):
379     """
380     Write a CopyResults part of a job script, e.g.
381     to copy produced output into a storage element.
382     """
383     txt = ''
384 fanzago 1.30 if int(self.copy_data) == 1:
385 fanzago 1.14 txt += '#\n'
386 fanzago 1.15 txt += '# Copy output to SE = $SE\n'
387 fanzago 1.14 txt += '#\n'
388 fanzago 1.66 #txt += 'if [ $exe_result -eq 0 ]; then\n'
389 gutsche 1.73 txt += ' if [ $middleware == OSG ]; then\n'
390     txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
391     txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
392     txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n'
393     txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
394     txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
395     txt += ' fi \n'
396 corvo 1.34 txt += ' for out_file in $file_list ; do\n'
397 gutsche 1.73 txt += ' echo "Trying to copy output file to $SE using lcg-cp"\n'
398 mkirn 1.77 if common.logger.debugLevel() >= 5:
399     txt += ' echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
400     txt += ' exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
401     else:
402     txt += ' echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
403     txt += ' exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
404 gutsche 1.73 txt += ' copy_exit_status=$?\n'
405     txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
406 corvo 1.34 txt += ' echo "STAGE_OUT = $copy_exit_status"\n'
407     txt += ' if [ $copy_exit_status -ne 0 ]; then\n'
408 gutsche 1.73 txt += ' echo "Possible problem with SE = $SE"\n'
409 corvo 1.34 txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
410     txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
411 mkirn 1.77 txt += ' echo "lcg-cp failed. For verbose lcg-cp output, use command line option -debug 5."\n'
412 gutsche 1.73 txt += ' echo "lcg-cp failed, attempting srmcp"\n'
413     txt += ' echo "mkdir -p $HOME/.srmconfig"\n'
414     txt += ' mkdir -p $HOME/.srmconfig\n'
415     txt += ' if [ $middleware == LCG ]; then\n'
416 mkirn 1.74 txt += ' echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
417     txt += ' exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
418 gutsche 1.73 txt += ' elif [ $middleware == OSG ]; then\n'
419     txt += ' echo "srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $OSG_APP/glite/etc/grid-security/certificates file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
420     txt += ' exitstring=`srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $OSG_APP/glite/etc/grid-security/certificates file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
421     txt += ' fi \n'
422     txt += ' copy_exit_status=$?\n'
423     txt += ' echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
424     txt += ' echo "STAGE_OUT = $copy_exit_status"\n'
425     txt += ' if [ $copy_exit_status -ne 0 ]; then\n'
426     txt += ' echo "Problems with SE = $SE"\n'
427     txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
428     txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
429     txt += ' echo "lcg-cp and srm failed"\n'
430     txt += ' echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
431     txt += ' else\n'
432     txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
433     txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
434     txt += ' echo "output copied into $SE/$SE_PATH directory"\n'
435     txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
436     txt += ' echo "srmcp succeeded"\n'
437     txt += ' fi\n'
438 corvo 1.34 txt += ' else\n'
439     txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
440     txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
441     txt += ' echo "output copied into $SE/$SE_PATH directory"\n'
442     txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
443 gutsche 1.73 txt += ' echo "lcg-cp succeeded"\n'
444 corvo 1.34 txt += ' fi\n'
445     txt += ' done\n'
446 fanzago 1.66 #txt += 'fi\n'
447 fanzago 1.14 return txt
448    
449     def wsRegisterOutput(self):
450     """
451     Returns part of a job script which does scheduler-specific work.
452     """
453    
454     txt = ''
455 fanzago 1.30 if int(self.register_data) == 1:
456 spiga 1.49 ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
457     txt += 'if [ $middleware == OSG ]; then\n'
458     txt += ' #\n'
459     txt += ' # Register output to LFC deactivated in OSG mode\n'
460     txt += ' #\n'
461     txt += ' echo "Register output to LFC deactivated in OSG mode"\n'
462     txt += 'elif [ $middleware == LCG ]; then \n'
463 fanzago 1.14 txt += '#\n'
464 fanzago 1.36 txt += '# Register output to LFC\n'
465 fanzago 1.14 txt += '#\n'
466 fanzago 1.66 #txt += ' if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
467     txt += ' if [ $copy_exit_status -eq 0 ]; then\n'
468 spiga 1.49 txt += ' for out_file in $file_list ; do\n'
469     txt += ' echo "Trying to register the output file into LFC"\n'
470 fanzago 1.68 #### FEDE
471     #txt += ' echo "which lcg-rf" \n'
472     #txt += ' which lcg-rf \n'
473     #########
474 fanzago 1.71 txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
475 fanzago 1.70 txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
476 fanzago 1.14 txt += ' register_exit_status=$?\n'
477 fanzago 1.15 txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
478     txt += ' echo "STAGE_OUT = $register_exit_status"\n'
479 fanzago 1.14 txt += ' if [ $register_exit_status -ne 0 ]; then \n'
480 spiga 1.49 txt += ' echo "Problems with the registration to LFC" \n'
481     txt += ' echo "Try with srm protocol" \n'
482 fanzago 1.68 #### FEDE
483     #txt += ' echo "which lcg-rf" \n'
484     #txt += ' which lcg-rf \n'
485     #########
486 fanzago 1.71 txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
487 fanzago 1.70 txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
488 spiga 1.49 txt += ' register_exit_status=$?\n'
489     txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
490     txt += ' echo "STAGE_OUT = $register_exit_status"\n'
491     txt += ' if [ $register_exit_status -ne 0 ]; then \n'
492     txt += ' echo "Problems with the registration into LFC" \n'
493     txt += ' fi \n'
494     txt += ' else \n'
495     txt += ' echo "output registered to LFC"\n'
496 fanzago 1.14 txt += ' fi \n'
497 spiga 1.49 txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
498     txt += ' done\n'
499 fanzago 1.66 #txt += ' elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
500     txt += ' else \n'
501 spiga 1.49 txt += ' echo "Trying to copy output file to CloseSE"\n'
502     txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
503     txt += ' for out_file in $file_list ; do\n'
504 fanzago 1.68 #### FEDE
505     #txt += ' echo "which lcg-cr" \n'
506     #txt += ' which lcg-cr \n'
507     #########
508 fanzago 1.71 txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1" \n'
509 fanzago 1.70 txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1 \n'
510 spiga 1.49 txt += ' register_exit_status=$?\n'
511     txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
512     txt += ' echo "STAGE_OUT = $register_exit_status"\n'
513     txt += ' if [ $register_exit_status -ne 0 ]; then \n'
514 fanzago 1.66 txt += ' echo "Problems with CloseSE or Catalog" \n'
515 spiga 1.49 txt += ' else \n'
516     txt += ' echo "The program was successfully executed"\n'
517     txt += ' echo "SE = $CLOSE_SE"\n'
518     txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n'
519     txt += ' fi \n'
520     txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
521     txt += ' done\n'
522 fanzago 1.66 #txt += ' else\n'
523     #txt += ' echo "Problem with the executable"\n'
524 spiga 1.49 txt += ' fi \n'
525 fanzago 1.68 txt += ' exit_status=$register_exit_status\n'
526 fanzago 1.14 txt += 'fi \n'
527     return txt
528 nsmirnov 1.1
529 spiga 1.23 def loggingInfo(self, id):
530 slacapra 1.7 """
531     retrieve the logging info from logging and bookkeeping and return it
532     """
533 slacapra 1.18 self.checkProxy()
534 fanzago 1.24 cmd = 'edg-job-get-logging-info -v 2 ' + id
535 slacapra 1.32 #cmd_out = os.popen(cmd)
536     cmd_out = runCommand(cmd)
537 slacapra 1.7 return cmd_out
538    
539 slacapra 1.6 def listMatch(self, nj):
540     """
541     Check the compatibility of available resources
542     """
543 slacapra 1.18 self.checkProxy()
544 slacapra 1.6 jdl = common.job_list[nj].jdlFilename()
545 slacapra 1.18 cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
546 mkirn 1.74 cmd_out = runCommand(cmd,0,45)
547 slacapra 1.44 if not cmd_out:
548     raise CrabException("ERROR: "+cmd+" failed!")
549    
550 slacapra 1.6 return self.parseListMatch_(cmd_out, jdl)
551    
552     def parseListMatch_(self, out, jdl):
553 slacapra 1.31 """
554     Parse the f* output of edg-list-match and produce something sensible
555     """
556 slacapra 1.6 reComment = re.compile( r'^\**$' )
557     reEmptyLine = re.compile( r'^$' )
558     reVO = re.compile( r'Selected Virtual Organisation name.*' )
559 slacapra 1.31 reLine = re.compile( r'.*')
560     reCE = re.compile( r'(.*:.*)')
561     reCEId = re.compile( r'CEId.*')
562 slacapra 1.6 reNO = re.compile( r'No Computing Element matching' )
563     reRB = re.compile( r'Connecting to host' )
564     next = 0
565     CEs=[]
566     Match=0
567 slacapra 1.22
568 slacapra 1.31 #print out
569     lines = reLine.findall(out)
570    
571     i=0
572     CEs=[]
573     for line in lines:
574     string.strip(line)
575     #print line
576     if reNO.match( line ):
577     common.logger.debug(5,line)
578     return 0
579     pass
580 fanzago 1.28 if reVO.match( line ):
581 slacapra 1.31 VO =reVO.match( line ).group()
582     common.logger.debug(5,"VO "+VO)
583 fanzago 1.28 pass
584 slacapra 1.31
585 fanzago 1.28 if reRB.match( line ):
586 slacapra 1.31 RB = reRB.match(line).group()
587     common.logger.debug(5,"RB "+RB)
588 fanzago 1.28 pass
589 slacapra 1.31
590     if reCEId.search( line ):
591     for lineCE in lines[i:-1]:
592     if reCE.match( lineCE ):
593     CE = string.strip(reCE.search(lineCE).group(1))
594     CEs.append(CE.split(':')[0])
595     pass
596     pass
597 fanzago 1.28 pass
598 slacapra 1.31 i=i+1
599     pass
600    
601     common.logger.debug(5,"All CE :"+str(CEs))
602    
603     sites = []
604     [sites.append(it) for it in CEs if not sites.count(it)]
605    
606     common.logger.debug(5,"All Sites :"+str(sites))
607 gutsche 1.56 common.logger.message("Matched Sites :"+str(sites))
608 slacapra 1.31 return len(sites)
609 slacapra 1.6
610     def noMatchFound_(self, jdl):
611     reReq = re.compile( r'Requirements' )
612     reString = re.compile( r'"\S*"' )
613     f = file(jdl,'r')
614     for line in f.readlines():
615     line= line.strip()
616     if reReq.match(line):
617     for req in reString.findall(line):
618     if re.search("VO",req):
619     common.logger.message( "SW required: "+req)
620     continue
621     if re.search('"\d+',req):
622     common.logger.message("Other req : "+req)
623     continue
624     common.logger.message( "CE required: "+req)
625     break
626     pass
627     raise CrabException("No compatible resources found!")
628    
629 nsmirnov 1.1 def submit(self, nj):
630 nsmirnov 1.3 """
631     Submit one EDG job.
632     """
633 nsmirnov 1.1
634 slacapra 1.18 self.checkProxy()
635 nsmirnov 1.1 jid = None
636     jdl = common.job_list[nj].jdlFilename()
637 slacapra 1.18
638     cmd = 'edg-job-submit ' + self.configOpt_() + jdl
639 nsmirnov 1.1 cmd_out = runCommand(cmd)
640     if cmd_out != None:
641 slacapra 1.18 reSid = re.compile( r'https.+' )
642 slacapra 1.20 jid = reSid.search(cmd_out).group()
643 nsmirnov 1.3 pass
644 nsmirnov 1.1 return jid
645    
646 fanzago 1.33 def resubmit(self, nj_list):
647     """
648     Prepare jobs to be submit
649     """
650     return
651    
652 slacapra 1.8 def getExitStatus(self, id):
653     return self.getStatusAttribute_(id, 'exit_code')
654 fanzago 1.10
655 nsmirnov 1.1 def queryStatus(self, id):
656 slacapra 1.8 return self.getStatusAttribute_(id, 'status')
657 fanzago 1.10
658 spiga 1.9 def queryDest(self, id):
659     return self.getStatusAttribute_(id, 'destination')
660    
661 slacapra 1.8
662     def getStatusAttribute_(self, id, attr):
663 nsmirnov 1.1 """ Query a status of the job with id """
664 slacapra 1.8
665 slacapra 1.18 self.checkProxy()
666 slacapra 1.8 hstates = {}
667 fanzago 1.12 Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status')
668 slacapra 1.8 # Bypass edg-job-status interfacing directly to C++ API
669     # Job attribute vector to retrieve status without edg-job-status
670     level = 0
671     # Instance of the Status class provided by LB API
672     jobStat = Status()
673     st = 0
674     jobStat.getStatus(id, level)
675     err, apiMsg = jobStat.get_error()
676     if err:
677 fanzago 1.26 common.logger.debug(5,'Error caught' + apiMsg)
678 nsmirnov 1.1 return None
679 slacapra 1.8 else:
680     for i in range(len(self.states)):
681     # Fill an hash table with all information retrieved from LB API
682     hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
683     result = jobStat.loadStatus(st)[ self.states.index(attr) ]
684     return result
685 nsmirnov 1.1
686     def queryDetailedStatus(self, id):
687     """ Query a detailed status of the job with id """
688     cmd = 'edg-job-status '+id
689     cmd_out = runCommand(cmd)
690     return cmd_out
691    
692     def getOutput(self, id):
693 nsmirnov 1.5 """
694     Get output for a finished job with id.
695     Returns the name of directory with results.
696     """
697 slacapra 1.6
698 slacapra 1.18 self.checkProxy()
699 slacapra 1.6 cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
700 nsmirnov 1.1 cmd_out = runCommand(cmd)
701 nsmirnov 1.5
702     # Determine the output directory name
703     dir = common.work_space.resDir()
704 corvo 1.55 dir += os.environ['USER']
705 nsmirnov 1.5 dir += '_' + os.path.basename(id)
706     return dir
707 nsmirnov 1.1
708     def cancel(self, id):
709     """ Cancel the EDG job with id """
710 slacapra 1.18 self.checkProxy()
711 nsmirnov 1.1 cmd = 'edg-job-cancel --noint ' + id
712     cmd_out = runCommand(cmd)
713     return cmd_out
714    
715 fanzago 1.10 def createSchScript(self, nj):
716 nsmirnov 1.1 """
717     Create a JDL-file for EDG.
718     """
719    
720     job = common.job_list[nj]
721     jbt = job.type()
722     inp_sandbox = jbt.inputSandbox(nj)
723     out_sandbox = jbt.outputSandbox(nj)
724 fanzago 1.10 inp_storage_subdir = ''
725 nsmirnov 1.1
726     title = '# This JDL was generated by '+\
727     common.prog_name+' (version '+common.prog_version_str+')\n'
728     jt_string = ''
729 fanzago 1.14
730    
731 nsmirnov 1.1
732     SPL = inp_storage_subdir
733     if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
734    
735     jdl_fname = job.jdlFilename()
736     jdl = open(jdl_fname, 'w')
737     jdl.write(title)
738    
739     script = job.scriptFilename()
740     jdl.write('Executable = "' + os.path.basename(script) +'";\n')
741     jdl.write(jt_string)
742    
743 fanzago 1.14 ### only one .sh JDL has arguments:
744 slacapra 1.8
745 gutsche 1.56 ### Fabio
746     jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
747 nsmirnov 1.1 inp_box = 'InputSandbox = { '
748     inp_box = inp_box + '"' + script + '",'
749    
750     if inp_sandbox != None:
751     for fl in inp_sandbox:
752     inp_box = inp_box + ' "' + fl + '",'
753     pass
754     pass
755    
756     #if common.use_jam:
757     # inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
758 fanzago 1.40
759 corvo 1.34 # Marco (VERY TEMPORARY ML STUFF)
760     inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
761 gutsche 1.47 os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
762 corvo 1.34 os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
763     os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
764     os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
765     # End Marco
766 nsmirnov 1.1
767 fanzago 1.40 if (not jbt.additional_inbox_files == []):
768     inp_box = inp_box + ', '
769     for addFile in jbt.additional_inbox_files:
770     addFile = os.path.abspath(addFile)
771     inp_box = inp_box+' "'+addFile+'",'
772     pass
773 nsmirnov 1.1
774     if inp_box[-1] == ',' : inp_box = inp_box[:-1]
775     inp_box = inp_box + ' };\n'
776     jdl.write(inp_box)
777    
778     jdl.write('StdOutput = "' + job.stdout() + '";\n')
779     jdl.write('StdError = "' + job.stderr() + '";\n')
780 fanzago 1.14
781    
782     if job.stdout() == job.stderr():
783     out_box = 'OutputSandbox = { "' + \
784     job.stdout() + '", ".BrokerInfo",'
785     else:
786     out_box = 'OutputSandbox = { "' + \
787     job.stdout() + '", "' + \
788     job.stderr() + '", ".BrokerInfo",'
789    
790 fanzago 1.30 if int(self.return_data) == 1:
791 fanzago 1.14 if out_sandbox != None:
792     for fl in out_sandbox:
793     out_box = out_box + ' "' + fl + '",'
794     pass
795 nsmirnov 1.1 pass
796     pass
797 fanzago 1.14
798 nsmirnov 1.1 if out_box[-1] == ',' : out_box = out_box[:-1]
799     out_box = out_box + ' };'
800     jdl.write(out_box+'\n')
801    
802 fanzago 1.14
803 fanzago 1.38 req='Requirements = '
804 slacapra 1.62 noreq=req
805 gutsche 1.78 req = req + jbt.getRequirements(nj)
806 spiga 1.49 #### and USER REQUIREMENT
807 fanzago 1.38 if self.EDG_requirements:
808 slacapra 1.62 if (req != noreq):
809     req = req + ' && '
810     req = req + self.EDG_requirements
811 fanzago 1.48 #### FEDE #####
812     if self.EDG_ce_white_list:
813     ce_white_list = string.split(self.EDG_ce_white_list,',')
814     #print "req = ", req
815     for i in range(len(ce_white_list)):
816     if i == 0:
817 slacapra 1.62 if (req != noreq):
818     req = req + ' && '
819     req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
820 fanzago 1.48 pass
821     else:
822     req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
823     req = req + ')'
824    
825     if self.EDG_ce_black_list:
826     ce_black_list = string.split(self.EDG_ce_black_list,',')
827     for ce in ce_black_list:
828 slacapra 1.62 if (req != noreq):
829     req = req + ' && '
830     req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
831 fanzago 1.48 pass
832 slacapra 1.62
833 fanzago 1.48 ###############
834 slacapra 1.62 clockTime=480
835 fanzago 1.38 if self.EDG_clock_time:
836 slacapra 1.62 clockTime= self.EDG_clock_time
837     if (req != noreq):
838     req = req + ' && '
839     req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
840 fanzago 1.48
841 slacapra 1.62 cpuTime=1000
842 fanzago 1.38 if self.EDG_cpu_time:
843 slacapra 1.62 cpuTime=self.EDG_cpu_time
844     if (req != noreq):
845     req = req + ' && '
846     req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
847 gutsche 1.60
848 slacapra 1.62 if (req != noreq):
849 fanzago 1.14 req = req + ';\n'
850     jdl.write(req)
851    
852 nsmirnov 1.1 jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
853    
854     if ( self.EDG_retry_count ):
855     jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
856     pass
857    
858 slacapra 1.51 jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
859    
860 nsmirnov 1.1 jdl.close()
861     return
862 slacapra 1.18
863     def checkProxy(self):
864     """
865     Function to check the Globus proxy.
866     """
867     if (self.proxyValid): return
868     timeleft = -999
869 slacapra 1.50 minTimeLeft=10*3600 # in seconds
870 slacapra 1.51
871     minTimeLeftServer = 100 # in hours
872    
873 slacapra 1.50 #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
874     #cmd = 'voms-proxy-info -timeleft'
875     mustRenew = 0
876 fanzago 1.69 timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
877 slacapra 1.50 timeLeftServer = -999
878 fanzago 1.53 if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
879 slacapra 1.50 mustRenew = 1
880     else:
881 fanzago 1.69 timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
882 slacapra 1.50 if not timeLeftServer or not isInt(timeLeftServer):
883     mustRenew = 1
884 slacapra 1.54 elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
885 slacapra 1.50 mustRenew = 1
886     pass
887     pass
888    
889 slacapra 1.51 if mustRenew:
890 gutsche 1.58 common.logger.message( "No valid proxy found or remaining time of validity of already existing proxy shorter than 10 hours!\n Creating a user proxy with default length of 96h\n")
891 slacapra 1.79 cmd = 'voms-proxy-init -voms '+self.VO+' -valid 96:00'
892     if self.role:
893     cmd = 'voms-proxy-init -voms '+self.VO+':/'+self.VO+'/role='+self.role+' -valid 96:00'
894 slacapra 1.18 try:
895 slacapra 1.32 # SL as above: damn it!
896 slacapra 1.19 out = os.system(cmd)
897     if (out>0): raise CrabException("Unable to create a valid proxy!\n")
898 slacapra 1.18 except:
899     msg = "Unable to create a valid proxy!\n"
900     raise CrabException(msg)
901     pass
902 slacapra 1.51
903     ## now I do have a voms proxy valid, and I check the myproxy server
904     renewProxy = 0
905     cmd = 'myproxy-info -d -s '+self.proxyServer
906     cmd_out = runCommand(cmd,0,20)
907     if not cmd_out:
908     common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now')
909     renewProxy = 1
910     else:
911     # if myproxy exist but not long enough, renew
912     reTime = re.compile( r'timeleft: (\d+)' )
913     #print "<"+str(reTime.search( cmd_out ).group(1))+">"
914     if reTime.match( cmd_out ):
915     time = reTime.search( line ).group(1)
916     if time < minTimeLeftServer:
917     renewProxy = 1
918     common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
919     pass
920     pass
921    
922     # if not, create one.
923     if renewProxy:
924     cmd = 'myproxy-init -d -n -s '+self.proxyServer
925     out = os.system(cmd)
926     if (out>0):
927 fanzago 1.53 raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n")
928 slacapra 1.51 pass
929    
930     # cache proxy validity
931 slacapra 1.18 self.proxyValid=1
932     return
933 spiga 1.49
934 slacapra 1.18 def configOpt_(self):
935     edg_ui_cfg_opt = ' '
936     if self.edg_config:
937 slacapra 1.51 edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
938 slacapra 1.18 if self.edg_config_vo:
939 slacapra 1.51 edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
940 slacapra 1.18 return edg_ui_cfg_opt