28 def __init__(self, project_element, default_first_input_list, default_input_lists, check=True):
74 if 'name' in dict(project_element.attributes):
75 self.
name =
str(project_element.attributes[
'name'].firstChild.data)
77 raise XMLError(
'Project name not specified.')
81 num_events_elements = project_element.getElementsByTagName(
'numevents')
82 for num_events_element
in num_events_elements:
83 if num_events_element.parentNode == project_element:
86 raise XMLError(
'Number of events not specified.')
90 num_jobs_elements = project_element.getElementsByTagName(
'numjobs')
91 for num_jobs_element
in num_jobs_elements:
92 if num_jobs_element.parentNode == project_element:
93 self.
num_jobs =
int(num_jobs_element.firstChild.data)
97 max_files_per_job_elements = project_element.getElementsByTagName(
'maxfilesperjob')
98 for max_files_per_job_element
in max_files_per_job_elements:
99 if max_files_per_job_element.parentNode == project_element:
104 ups_elements = project_element.getElementsByTagName(
'ups')
105 for ups_element
in ups_elements:
106 self.ups.append(
str(ups_element.firstChild.data))
110 if len(self.
ups) == 0:
115 os_elements = project_element.getElementsByTagName(
'os')
116 for os_element
in os_elements:
117 if os_element.parentNode == project_element:
118 self.
os =
str(os_element.firstChild.data)
119 self.
os =
''.join(self.os.split())
123 resource_elements = project_element.getElementsByTagName(
'resource')
124 for resource_element
in resource_elements:
125 if resource_element.parentNode == project_element:
126 self.
resource =
str(resource_element.firstChild.data)
127 self.
resource =
''.join(self.resource.split())
131 role_elements = project_element.getElementsByTagName(
'role')
132 for role_element
in role_elements:
133 if role_element.parentNode == project_element:
134 self.
role =
str(role_element.firstChild.data)
138 lines_elements = project_element.getElementsByTagName(
'lines')
139 for lines_element
in lines_elements:
140 if lines_element.parentNode == project_element:
141 self.
lines =
str(lines_element.firstChild.data)
145 server_elements = project_element.getElementsByTagName(
'server')
146 for server_element
in server_elements:
147 if server_element.parentNode == project_element:
148 self.
server =
str(server_element.firstChild.data)
152 site_elements = project_element.getElementsByTagName(
'site')
153 for site_element
in site_elements:
154 if site_element.parentNode == project_element:
155 self.
site =
str(site_element.firstChild.data)
156 self.
site =
''.join(self.site.split())
160 blacklist_elements = project_element.getElementsByTagName(
'blacklist')
161 for blacklist_element
in blacklist_elements:
162 if blacklist_element.parentNode == project_element:
164 self.
blacklist =
''.join(self.blacklist.split())
168 cpu_elements = project_element.getElementsByTagName(
'cpu')
169 for cpu_element
in cpu_elements:
170 if cpu_element.parentNode == project_element:
171 self.
cpu =
int(cpu_element.firstChild.data)
175 disk_elements = project_element.getElementsByTagName(
'disk')
176 for disk_element
in disk_elements:
177 if disk_element.parentNode == project_element:
178 self.
disk =
str(disk_element.firstChild.data)
179 self.
disk =
''.join(self.disk.split())
183 memory_elements = project_element.getElementsByTagName(
'memory')
184 for memory_element
in memory_elements:
185 if memory_element.parentNode == project_element:
186 self.
memory =
int(memory_element.firstChild.data)
190 merge_elements = project_element.getElementsByTagName(
'merge')
191 for merge_element
in merge_elements:
192 if merge_element.parentNode == project_element:
193 if merge_element.firstChild:
194 self.
merge =
str(merge_element.firstChild.data)
200 anamerge_elements = project_element.getElementsByTagName(
'anamerge')
201 for anamerge_element
in anamerge_elements:
202 if anamerge_element.parentNode == project_element:
203 if anamerge_element.firstChild:
204 self.
anamerge =
str(anamerge_element.firstChild.data)
210 larsoft_elements = project_element.getElementsByTagName(
'larsoft')
215 tag_elements = larsoft_elements[0].getElementsByTagName(
'tag')
216 if tag_elements
and tag_elements[0].firstChild !=
None:
221 qual_elements = larsoft_elements[0].getElementsByTagName(
'qual')
228 local_elements = larsoft_elements[0].getElementsByTagName(
'local')
230 local =
str(local_elements[0].firstChild.data)
231 if larbatch_posix.isdir(local):
238 version_elements = project_element.getElementsByTagName(
'version')
240 self.
version =
str(version_elements[0].firstChild.data)
248 raise IOError(
"Local release directory/tarball %s does not exist." % self.
local_release_tar)
252 file_type_elements = project_element.getElementsByTagName(
'filetype')
253 if file_type_elements:
254 self.
file_type =
str(file_type_elements[0].firstChild.data)
258 run_type_elements = project_element.getElementsByTagName(
'runtype')
259 if run_type_elements:
260 self.
run_type =
str(run_type_elements[0].firstChild.data)
264 run_number_elements = project_element.getElementsByTagName(
'runnumber')
265 if run_number_elements:
266 self.
run_number =
int(run_number_elements[0].firstChild.data)
270 script_elements = project_element.getElementsByTagName(
'script')
271 for script_element
in script_elements:
272 if script_element.parentNode == project_element:
273 self.
script =
str(script_element.firstChild.data)
280 jobinfo = subprocess.Popen([
'which', self.
script],
281 stdout=subprocess.PIPE,
282 stderr=subprocess.PIPE)
283 jobout, joberr = jobinfo.communicate()
287 script_path = jobout.splitlines()[0].strip()
290 if script_path ==
'' or not larbatch_posix.access(script_path, os.X_OK):
291 raise IOError(
'Script %s not found.' % self.
script)
296 worker_validations = project_element.getElementsByTagName(
'check')
297 for worker_validation
in worker_validations:
298 if worker_validation.parentNode == project_element:
303 worker_copys = project_element.getElementsByTagName(
'copy')
304 for worker_copy
in worker_copys:
305 if worker_copy.parentNode == project_element:
310 cvmfs_elements = project_element.getElementsByTagName(
'cvmfs')
311 for cvmfs_element
in cvmfs_elements:
312 if cvmfs_element.parentNode == project_element:
313 self.
cvmfs =
int(cvmfs_element.firstChild.data)
317 stash_elements = project_element.getElementsByTagName(
'stash')
318 for stash_element
in stash_elements:
319 if stash_element.parentNode == project_element:
320 self.
stash =
int(stash_element.firstChild.data)
324 singularity_elements = project_element.getElementsByTagName(
'singularity')
325 for singularity_element
in singularity_elements:
326 if singularity_element.parentNode == project_element:
331 start_script_elements = project_element.getElementsByTagName(
'startscript')
332 for start_script_element
in start_script_elements:
333 if start_script_element.parentNode == project_element:
342 jobinfo = subprocess.Popen([
'which', self.
start_script],
343 stdout=subprocess.PIPE,
344 stderr=subprocess.PIPE)
345 jobout, joberr = jobinfo.communicate()
349 script_path = jobout.splitlines()[0].strip()
356 stop_script_elements = project_element.getElementsByTagName(
'stopscript')
357 for stop_script_element
in stop_script_elements:
358 if stop_script_element.parentNode == project_element:
367 jobinfo = subprocess.Popen([
'which', self.
stop_script],
368 stdout=subprocess.PIPE,
369 stderr=subprocess.PIPE)
370 jobout, joberr = jobinfo.communicate()
374 script_path = jobout.splitlines()[0].strip()
381 fclpath_elements = project_element.getElementsByTagName(
'fcldir')
382 for fclpath_element
in fclpath_elements:
383 self.fclpath.append(
str(fclpath_element.firstChild.data))
387 if check
and 'FHICL_FILE_PATH' in os.environ:
388 for fcldir
in os.environ[
'FHICL_FILE_PATH'].
split(
':'):
389 if larbatch_posix.exists(fcldir):
390 self.fclpath.append(fcldir)
396 if not larbatch_posix.exists(fcldir):
397 raise IOError(
"Fcl search directory %s does not exist." % fcldir)
401 stage_elements = project_element.getElementsByTagName(
'stage')
402 default_previous_stage =
'' 403 default_input_lists[default_previous_stage] = default_first_input_list
404 for stage_element
in stage_elements:
409 if 'base' in dict(stage_element.attributes):
410 base_name =
str(stage_element.attributes[
'base'].firstChild.data)
413 if stage.name == base_name:
417 if base_stage ==
None:
418 raise LookupError(
'Base stage %s not found.' % base_name)
420 self.stages.append(StageDef(stage_element,
423 default_previous_stage,
443 default_previous_stage = self.
stages[-1].name
444 default_input_lists[default_previous_stage] = os.path.join(self.
stages[-1].bookdir,
449 param_elements = project_element.getElementsByTagName(
'parameter')
450 for param_element
in param_elements:
451 name =
str(param_element.attributes[
'name'].firstChild.data)
452 value =
str(param_element.firstChild.data)
def __init__(self, project_element, default_first_input_list, default_input_lists, check=True)
void split(std::string const &s, char c, OutIter dest)