ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/multicrab.py
(Generate patch)

Comparing COMP/CRAB/python/multicrab.py (file contents):
Revision 1.7 by slacapra, Wed Jan 7 15:23:33 2009 UTC vs.
Revision 1.22.2.1 by spiga, Thu Apr 15 08:19:43 2010 UTC

# Line 25 | Line 25 | class MultiCrab:
25          print self.prog_name + ' running on ' +  time.ctime(time.time())
26          print '  working directory   ' + self.continue_dir
27  
28        crabs=[]
28  
29      def processContinueOption_(self,opts):
30  
# Line 99 | Line 98 | class MultiCrab:
98              if ( opt == '-cfg' ):
99                  if self.flag_continue:
100                      raise CrabException('-continue and -cfg cannot coexist.')
101 <                if opts[opt] : self.cfg_fname = opts[opt]
101 >                if opts[opt] :
102 >                    self.cfg_fname = opts[opt]
103 >                    del opts[opt] # do not pass cfg further on
104                  else : processHelpOptions()
105                  pass
106              pass
# Line 145 | Line 146 | class MultiCrab:
146          # first get common sections
147          for sec in cfg_params:
148              if sec in ['MULTICRAB']:
149 <                cfg_common=cfg_params[sec]
149 >                if 'cfg' in cfg_params[sec]:
150 >                    common_opts['cfg']=cfg_params[sec]['cfg']
151                  continue
152              if sec in ['COMMON']:
153 <                common_opts=cfg_params[sec]
153 >                common_opts.update(cfg_params[sec])
154                  continue
155              pass
156  
157 +        crab_cfg='crab.cfg'
158 +        if common_opts.has_key('cfg') : crab_cfg=common_opts['cfg']
159 +
160          # then Dataset's specific
161          for sec in cfg_params:
162              if sec in ['MULTICRAB', 'COMMON']: continue
# Line 161 | Line 166 | class MultiCrab:
166                  self.cfg_params_dataset[sec][key]=common_opts[key]
167              pass
168  
164        self.cfg=cfg_common['cfg']
165
169          # read crab.cfg file and search for storage_path
170 <        crab_cfg_params = loadConfig(self.cfg,{})
170 >        crab_cfg_params = loadConfig(crab_cfg,{})
171 >        # also USER.ui_working_dir USER.outputdir and USER.logdir need special treatment
172          if cfg_params.has_key("COMMON"):
173              self.user_remote_dir = cfg_params["COMMON"].get("user.user_remote_dir", crab_cfg_params.get("USER.user_remote_dir",None))
174 +            self.outputdir = cfg_params["COMMON"].get("user.outputdir", crab_cfg_params.get("USER.outputdir",None))
175 +            self.logdir = cfg_params["COMMON"].get("user.logdir", crab_cfg_params.get("USER.logdir",None))
176 +            self.ui_working_dir = cfg_params["COMMON"].get("user.ui_working_dir", crab_cfg_params.get("USER.ui_working_dir",None))
177          else:
178              self.user_remote_dir = crab_cfg_params.get("USER.user_remote_dir",None)
179 +            self.outputdir = crab_cfg_params.get("USER.outputdir",None)
180 +            self.logdir = crab_cfg_params.get("USER.logdir",None)
181 +            self.ui_working_dir = crab_cfg_params.get("USER.ui_working_dir",None)
182 +
183          return
184  
185      def loadMultiConfig(self, file):
# Line 189 | Line 200 | class MultiCrab:
200  
201      def run(self):
202          #run crabs
203 +        runFileName = 'multicrab.exe'
204 +        runFile = open(runFileName,"w")
205          for sec in self.cfg_params_dataset:
206              options={}
207              if self.flag_continue:
# Line 197 | Line 210 | class MultiCrab:
210              options['-USER.ui_working_dir']=sec
211              # options from multicrab.cfg
212              for opt in self.cfg_params_dataset[sec]:
213 <                tmp="-"+string.upper(opt.split(".")[0])+"."+opt.split(".")[1]
213 >                tmp = "-"+str(opt)
214 >                if len(opt.split("."))==2:
215 >                    tmp="-"+string.upper(opt.split(".")[0])+"."+opt.split(".")[1]
216 >                
217                  options[tmp]=self.cfg_params_dataset[sec][opt]
218 +
219 +            # protect against no user_remote_dir
220 +            self.user_remote_dir =self.cfg_params_dataset[sec].get("user.user_remote_dir",None)
221 +            if not self.user_remote_dir:
222 +                self.user_remote_dir = "./"
223              # add section to storage_path if exist in crab.cfg
224              if not self.cfg_params_dataset.has_key("USER.user_remote_dir") and self.user_remote_dir:
225                  options["-USER.user_remote_dir"]=self.user_remote_dir+"/"+sec
226 +            # also for ui_working_dir
227 +            if not self.cfg_params_dataset.has_key("USER.ui_working_dir") and self.ui_working_dir:
228 +                options["-USER.ui_working_dir"]=self.ui_working_dir+"/"+sec
229 +            # also for logDir
230 +            if not self.cfg_params_dataset.has_key("USER.logdir") and self.logdir:
231 +                options["-USER.logdir"]=self.logdir+"/"+sec
232 +            # also for outputdir
233 +            if not self.cfg_params_dataset.has_key("USER.outputdir") and self.outputdir:
234 +                options["-USER.outputdir"]=self.outputdir+"/"+sec
235 +
236              # Input options (command)
237              for opt in self.opts:
207                # remove -cfg
208                if opt=='-cfg': continue
238                  options[opt]=self.opts[opt]
239 <            try:
240 <                # print options
212 <                crab = Crab(options)
213 <                crab.run()
214 <                common.apmon.free()
215 <                del crab
216 <            except CrabException, e:
217 <                print '\n' + common.prog_name + ': ' + str(e) + '\n'
218 <                if common.logger:
219 <                    common.logger.write('ERROR: '+str(e)+'\n')
220 <                    pass
239 >                if self.flag_continue and options.has_key("-cfg"):
240 >                    del options['-cfg']
241                  pass
242 <            pass
242 >
243 >            # write crab command to be executed later...
244 >            cmd='crab '
245 >            for o in options:
246 >                if options[o]==None:
247 >                    cmd+=str(o)+' '
248 >                else:
249 >                    options[o] = ''.join(options[o].split())
250 >                    cmd+=str(o)+'='+str(options[o])+' '
251 >                pass
252 >            cmd+="\n"
253 >            #print cmd
254 >
255 >            runFile.write(cmd)
256 >
257 >            # SL this does not work for complex, multi include pset.py
258 >
259 >            # crab = Crab()
260 >            # try:
261 >            #     crab.initialize_(options)
262 >            #     crab.run()
263 >            #     del crab
264 >            #     print 'Log file is %s%s.log'%(common.work_space.logDir(),common.prog_name)  
265 >            #     print '\n##############################  E N D  ####################################\n'
266 >            # except CrabException, e:
267 >            #     del crab
268 >            #     print '\n' + common.prog_name + ': ' + str(e) + '\n'
269 >            #     pass
270 >            # pass
271 >            # if (common.logger): common.logger.delete()
272          pass
273          
225        #common.apmon.free()
274  
275   ###########################################################################
276   if __name__ == '__main__':

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines