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.6 by slacapra, Tue Dec 2 15:41:29 2008 UTC vs.
Revision 1.8 by slacapra, Fri Jan 9 14:19:29 2009 UTC

# Line 99 | Line 99 | class MultiCrab:
99              if ( opt == '-cfg' ):
100                  if self.flag_continue:
101                      raise CrabException('-continue and -cfg cannot coexist.')
102 <                if opts[opt] : self.cfg_fname = opts[opt]
102 >                if opts[opt] :
103 >                    self.cfg_fname = opts[opt]
104 >                    opts.remove[opt]
105                  else : processHelpOptions()
106                  pass
107              pass
# Line 116 | Line 118 | class MultiCrab:
118  
119          # Load cfg-file
120  
121 +        cfg_params = {}
122          if self.cfg_fname != None:
123              if os.path.exists(self.cfg_fname):
124 <                self.cfg_params = self.loadMultiConfig(self.cfg_fname)
124 >                cfg_params = self.loadMultiConfig(self.cfg_fname)
125                  pass
126              else:
127                  msg = 'cfg-file '+self.cfg_fname+' not found.'
# Line 129 | Line 132 | class MultiCrab:
132          # process the [CRAB] section
133  
134          lhp = len('MULTICRAB.')
135 <        for k in self.cfg_params.keys():
135 >        for k in cfg_params.keys():
136              if len(k) >= lhp and k[:lhp] == 'MULTICRAB.':
137                  opt = '-'+k[lhp:]
138                  if len(opt) >= 3 and opt[:3] == '-__': continue
139                  if opt not in opts.keys():
140 <                    opts[opt] = self.cfg_params[k]
140 >                    opts[opt] = cfg_params[k]
141                      pass
142                  pass
143              pass
# Line 142 | Line 145 | class MultiCrab:
145          self.cfg_params_dataset = {}
146          common_opts = {}
147          # first get common sections
148 <        for sec in self.cfg_params:
148 >        for sec in cfg_params:
149              if sec in ['MULTICRAB']:
150 <                cfg_common=self.cfg_params[sec]
150 >                if 'cfg' in cfg_params[sec]:
151 >                    common_opts['cfg']=cfg_params[sec]['cfg']
152                  continue
153              if sec in ['COMMON']:
154 <                common_opts=self.cfg_params[sec]
154 >                common_opts.update(cfg_params[sec])
155                  continue
156              pass
157  
158 +        crab_cfg='crab.cfg'
159 +        if common_opts.has_key('cfg') : crab_cfg=common_opts['cfg']
160 +
161          # then Dataset's specific
162 <        for sec in self.cfg_params:
162 >        for sec in cfg_params:
163              if sec in ['MULTICRAB', 'COMMON']: continue
164 <            self.cfg_params_dataset[sec]=self.cfg_params[sec]
164 >            self.cfg_params_dataset[sec]=cfg_params[sec]
165              # add common to all dataset
166              for key in common_opts:
167                  self.cfg_params_dataset[sec][key]=common_opts[key]
168              pass
169  
163        self.cfg=cfg_common['cfg']
164
170          # read crab.cfg file and search for storage_path
171 <        cfg_params = loadConfig(self.cfg,{})
172 <        if self.cfg_params.has_key("COMMON"):
173 <            self.user_remote_dir = self.cfg_params["COMMON"].get("user.user_remote_dir", cfg_params.get("USER.user_remote_dir",None))
171 >        crab_cfg_params = loadConfig(crab_cfg,{})
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          else:
175 <            self.user_remote_dir = cfg_params.get("USER.user_remote_dir",None)
175 >            self.user_remote_dir = crab_cfg_params.get("USER.user_remote_dir",None)
176          return
177  
178      def loadMultiConfig(self, file):
# Line 196 | Line 201 | class MultiCrab:
201              options['-USER.ui_working_dir']=sec
202              # options from multicrab.cfg
203              for opt in self.cfg_params_dataset[sec]:
204 <                tmp="-"+string.upper(opt.split(".")[0])+"."+opt.split(".")[1]
204 >                tmp = "-"+str(opt)
205 >                if len(opt.split("."))==2:
206 >                    tmp="-"+string.upper(opt.split(".")[0])+"."+opt.split(".")[1]
207 >                
208                  options[tmp]=self.cfg_params_dataset[sec][opt]
209              # add section to storage_path if exist in crab.cfg
210              if not self.cfg_params_dataset.has_key("USER.user_remote_dir") and self.user_remote_dir:
# Line 205 | Line 213 | class MultiCrab:
213              for opt in self.opts:
214                  options[opt]=self.opts[opt]
215              try:
208                #print options
216                  crab = Crab(options)
217                  crab.run()
218                  common.apmon.free()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines