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.10 by slacapra, Wed Mar 4 13:03:24 2009 UTC vs.
Revision 1.27 by slacapra, Fri Jul 2 15:00:00 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 101 | Line 100 | class MultiCrab:
100                      raise CrabException('-continue and -cfg cannot coexist.')
101                  if opts[opt] :
102                      self.cfg_fname = opts[opt]
103 <                    opts.remove[opt]
103 >                    del opts[opt] # do not pass cfg further on
104                  else : processHelpOptions()
105                  pass
106              pass
# Line 169 | Line 168 | class MultiCrab:
168  
169          # read crab.cfg file and search for storage_path
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 193 | 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 206 | Line 215 | class MultiCrab:
215                      tmp="-"+string.upper(opt.split(".")[0])+"."+opt.split(".")[1]
216                  
217                  options[tmp]=self.cfg_params_dataset[sec][opt]
218 +
219 +            # check if user_remote_dir is set in multicrab.cfg
220 +            # protect against no user_remote_dir
221 +            self.user_remote_dir =self.cfg_params_dataset[sec].get("user.user_remote_dir",self.user_remote_dir)
222 +            if not self.user_remote_dir:
223 +                self.user_remote_dir = "./"
224              # add section to storage_path if exist in crab.cfg
225              if not self.cfg_params_dataset.has_key("USER.user_remote_dir") and self.user_remote_dir:
226                  options["-USER.user_remote_dir"]=self.user_remote_dir+"/"+sec
227 +            # print options["-USER.user_remote_dir"]
228 +            # also for ui_working_dir
229 +            if not self.cfg_params_dataset.has_key("USER.ui_working_dir") and self.ui_working_dir:
230 +                options["-USER.ui_working_dir"]=self.ui_working_dir+"/"+sec
231 +            # if ui_working_dir is set, change -c dir accordnigly
232 +                options['-c']=self.ui_working_dir+"/"+sec
233 +
234 +            # also for logDir
235 +            if not self.cfg_params_dataset.has_key("USER.logdir") and self.logdir:
236 +                options["-USER.logdir"]=self.logdir+"/"+sec
237 +            # also for outputdir
238 +            if not self.cfg_params_dataset.has_key("USER.outputdir") and self.outputdir:
239 +                options["-USER.outputdir"]=self.outputdir+"/"+sec
240 +
241              # Input options (command)
242              for opt in self.opts:
243                  options[opt]=self.opts[opt]
244                  if self.flag_continue and options.has_key("-cfg"):
245                      del options['-cfg']
217            try:
218                crab = Crab(options)
219                crab.run()
220                common.apmon.free()
221                del crab
222                print '\n##############################  E N D  ####################################\n'
223            except CrabException, e:
224                print '\n' + common.prog_name + ': ' + str(e) + '\n'
225                if common.logger:
226                    common.logger.write('ERROR: '+str(e)+'\n')
227                    pass
246                  pass
247 <            pass
247 >
248 >            # write crab command to be executed later...
249 >            cmd='crab '
250 >            for o in options:
251 >                if options[o]==None:
252 >                    cmd+=str(o)+' '
253 >                else:
254 >                    options[o] = ''.join(options[o].split())
255 >                    cmd+=str(o)+'='+str(options[o])+' '
256 >                pass
257 >            cmd+="\n"
258 >            #print cmd
259 >
260 >            runFile.write(cmd)
261 >
262 >            # SL this does not work for complex, multi include pset.py
263 >
264 >            # crab = Crab()
265 >            # try:
266 >            #     crab.initialize_(options)
267 >            #     crab.run()
268 >            #     del crab
269 >            #     print 'Log file is %s%s.log'%(common.work_space.logDir(),common.prog_name)  
270 >            #     print '\n##############################  E N D  ####################################\n'
271 >            # except CrabException, e:
272 >            #     del crab
273 >            #     print '\n' + common.prog_name + ': ' + str(e) + '\n'
274 >            #     pass
275 >            # pass
276 >            # if (common.logger): common.logger.delete()
277          pass
278          
232        #common.apmon.free()
279  
280   ###########################################################################
281   if __name__ == '__main__':

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines