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.29 by slacapra, Wed Oct 26 11:43:40 2011 UTC vs.
Revision 1.32 by slacapra, Thu Apr 26 14:10:25 2012 UTC

# Line 83 | Line 83 | class MultiCrab:
83              try:
84                  os.mkdir(self.continue_dir)
85              except OSError:
86 <                msg = 'Cannot create '+str(self.continue_dir) +' directory.\n'
86 >                msg = 'ERROR: Cannot create '+str(self.continue_dir) +' directory.\n'
87                  raise CrabException(msg)
88              pass
89          else:
90 <            msg = 'Directory '+str(self.continue_dir) +' already exist.\n'
90 >            msg = 'ERROR: Directory '+str(self.continue_dir) +' already exist.\n'
91              raise CrabException(msg)
92  
93          os.putenv("MULTICRAB_WORKDIR",self.continue_dir)
# Line 131 | Line 131 | class MultiCrab:
131                  cfg_params = self.loadMultiConfig(self.cfg_fname)
132                  pass
133              else:
134 <                msg = 'cfg-file '+self.cfg_fname+' not found.'
134 >                msg = 'ERROR: cfg-file '+self.cfg_fname+' not found.'
135                  raise CrabException(msg)
136                  pass
137              pass
# Line 163 | Line 163 | class MultiCrab:
163              pass
164  
165          crab_cfg='crab.cfg'
166        if common_opts.has_key('cfg') : crab_cfg=common_opts['cfg']
167
168        # then Dataset's specific
169        for sec in cfg_params:
170            if sec in ['MULTICRAB', 'COMMON']: continue
171            self.cfg_params_dataset[sec]=cfg_params[sec]
172            # add common to all dataset
173            for key in common_opts:
174                self.cfg_params_dataset[sec][key]=common_opts[key]
175            pass
176
166          # read crab.cfg file and search for storage_path
167          crab_cfg_params = loadConfig(crab_cfg,{})
168          # also USER.ui_working_dir USER.outputdir and USER.logdir need special treatment
# Line 184 | Line 173 | class MultiCrab:
173              self.ui_working_dir = cfg_params["COMMON"].get("user.ui_working_dir", crab_cfg_params.get("USER.ui_working_dir",None))
174              self.publish_data_name = cfg_params["COMMON"].get("user.publish_data_name", crab_cfg_params.get("USER.publish_data_name",None))
175          else:
176 <            self.user_remote_dir = crab_cfg_params.get("USER.user_remote_dir",None)
176 >            self.user_remote_dir = crab_cfg_params.get("USER.user_remote_dir","./")
177              self.outputdir = crab_cfg_params.get("USER.outputdir",None)
178              self.logdir = crab_cfg_params.get("USER.logdir",None)
179              self.ui_working_dir = crab_cfg_params.get("USER.ui_working_dir",None)
180              self.publish_data_name = crab_cfg_params.get("USER.publish_data_name",None)
181 +        print "self.publish_data_name ",self.publish_data_name
182 +
183 +        if common_opts.has_key('cfg') : crab_cfg=common_opts['cfg']
184 +
185 +        # then Dataset's specific
186 +        for sec in cfg_params:
187 +            if sec in ['MULTICRAB', 'COMMON']: continue
188 +            # add common to all dataset
189 +            self.cfg_params_dataset[sec]=cfg_params[sec]
190 +            # special tratment for some parameter
191 +            if not self.cfg_params_dataset[sec].has_key("user.publish_data_name") and self.publish_data_name:
192 +                self.cfg_params_dataset[sec]["user.publish_data_name"]=self.publish_data_name+"_"+sec
193 +            if not self.cfg_params_dataset[sec].has_key("user.user_remote_dir") and self.user_remote_dir:
194 +                self.cfg_params_dataset[sec]["user.user_remote_dir"]=self.user_remote_dir+"/"+sec
195 +            if not self.cfg_params_dataset[sec].has_key("user.ui_working_dir") and self.ui_working_dir:
196 +                self.cfg_params_dataset[sec]["user.ui_working_dir"]=self.ui_working_dir+"/"+sec
197 +            if not self.cfg_params_dataset[sec].has_key("user.logdir") and self.logdir:
198 +                self.cfg_params_dataset[sec]["user.logdir"]=self.logdir+"/"+sec
199 +            if not self.cfg_params_dataset[sec].has_key("user.outputdir") and self.outputdir:
200 +                self.cfg_params_dataset[sec]["user.outputdir"]=self.outputdir+"/"+sec
201 +            for key in common_opts:
202 +                if not self.cfg_params_dataset[sec].has_key(key):
203 +                    self.cfg_params_dataset[sec][key]=common_opts[key]
204 +            pass
205 +
206  
207          return
208  
# Line 204 | Line 218 | class MultiCrab:
218              # print 'Section',sec
219              config[sec]={}
220              for opt in cp.options(sec):
221 <                #print 'config['+sec+'.'+opt+'] = '+string.strip(cp.get(sec,opt))
221 >                # print 'config['+sec+'.'+opt+'] = '+string.strip(cp.get(sec,opt))
222                  config[sec][opt] = string.strip(cp.get(sec,opt))
223          return config
224  
# Line 226 | Line 240 | class MultiCrab:
240                  
241                  options[tmp]=self.cfg_params_dataset[sec][opt]
242  
243 +            # if ui_working_dir is set, change -c dir accordnigly
244 +            if not self.cfg_params_dataset.has_key("USER.ui_working_dir") and self.ui_working_dir:
245 +                if self.flag_continue:
246 +                    options['-c']=self.ui_working_dir+"/"+sec
247 +
248              # check if user_remote_dir is set in multicrab.cfg
249              # protect against no user_remote_dir
250 <            self.user_remote_dir =self.cfg_params_dataset[sec].get("user.user_remote_dir",self.user_remote_dir)
251 <            if not self.user_remote_dir:
252 <                self.user_remote_dir = "./"
250 >            # self.user_remote_dir =self.cfg_params_dataset[sec].get("user.user_remote_dir",self.user_remote_dir)
251 >            # if not self.user_remote_dir:
252 >            #     self.user_remote_dir = "./"
253              # add section to storage_path if exist in crab.cfg
254 <            if not self.cfg_params_dataset.has_key("USER.user_remote_dir") and self.user_remote_dir:
255 <                options["-USER.user_remote_dir"]=self.user_remote_dir+"/"+sec
254 >            # if not self.cfg_params_dataset.has_key("USER.user_remote_dir") and self.user_remote_dir:
255 >            #     options["-USER.user_remote_dir"]=self.user_remote_dir+"/"+sec
256              # print options["-USER.user_remote_dir"]
257              # also for ui_working_dir
258 <            if not self.cfg_params_dataset.has_key("USER.ui_working_dir") and self.ui_working_dir:
259 <                options["-USER.ui_working_dir"]=self.ui_working_dir+"/"+sec
241 <            # if ui_working_dir is set, change -c dir accordnigly
242 <                if self.flag_continue:
243 <                    options['-c']=self.ui_working_dir+"/"+sec
244 <
258 >            # if not self.cfg_params_dataset.has_key("USER.ui_working_dir") and self.ui_working_dir:
259 >            #     options["-USER.ui_working_dir"]=self.ui_working_dir+"/"+sec
260              # also for logDir
261 <            if not self.cfg_params_dataset.has_key("USER.logdir") and self.logdir:
262 <                options["-USER.logdir"]=self.logdir+"/"+sec
263 <            # also for outputdir
264 <            if not self.cfg_params_dataset.has_key("USER.outputdir") and self.outputdir:
265 <                options["-USER.outputdir"]=self.outputdir+"/"+sec
261 >            # if not self.cfg_params_dataset.has_key("USER.logdir") and self.logdir:
262 >            #     options["-USER.logdir"]=self.logdir+"/"+sec
263 >            # # also for outputdir
264 >            # if not self.cfg_params_dataset.has_key("USER.outputdir") and self.outputdir:
265 >            #     options["-USER.outputdir"]=self.outputdir+"/"+sec
266              # also for publish_data_name
267 <            if not self.cfg_params_dataset.has_key("USER.publish_data_name") and self.publish_data_name:
268 <                options["-USER.publish_data_name"]=self.publish_data_name+"_"+sec
267 >            # print sec," ",self.cfg_params_dataset[sec], self.cfg_params_dataset[sec].has_key("user.publish_data_name")
268 >            # if not self.cfg_params_dataset[sec].has_key("user.publish_data_name") and self.publish_data_name:
269 >            #     options["-USER.publish_data_name"]=self.publish_data_name+"_"+sec
270 >            #     print "adding user.publish_data_name", self.cfg_params_dataset.has_key("user.publish_data_name")
271  
272              # Input options (command)
273              for opt in self.opts:
# Line 261 | Line 278 | class MultiCrab:
278                          del options['-cfg']
279                      pass
280  
281 +
282              # write crab command to be executed later...
283              cmd='crab '
284              for o in options:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines