29 def __init__(self, project_element, default_first_input_list, default_input_lists, check=True):
75 if 'name' in dict(project_element.attributes):
76 self.
name = str(project_element.attributes[
'name'].firstChild.data)
78 raise XMLError(
'Project name not specified.')
82 num_events_elements = project_element.getElementsByTagName(
'numevents')
83 for num_events_element
in num_events_elements:
84 if num_events_element.parentNode == project_element:
85 self.
num_events = int(num_events_element.firstChild.data)
87 raise XMLError(
'Number of events not specified.')
91 num_jobs_elements = project_element.getElementsByTagName(
'numjobs')
92 for num_jobs_element
in num_jobs_elements:
93 if num_jobs_element.parentNode == project_element:
94 self.
num_jobs = int(num_jobs_element.firstChild.data)
98 max_files_per_job_elements = project_element.getElementsByTagName(
'maxfilesperjob')
99 for max_files_per_job_element
in max_files_per_job_elements:
100 if max_files_per_job_element.parentNode == project_element:
105 ups_elements = project_element.getElementsByTagName(
'ups')
106 for ups_element
in ups_elements:
107 self.ups.append(str(ups_element.firstChild.data))
111 if len(self.
ups) == 0:
116 os_elements = project_element.getElementsByTagName(
'os')
117 for os_element
in os_elements:
118 if os_element.parentNode == project_element:
119 self.
os = str(os_element.firstChild.data)
120 self.
os =
''.
join(self.os.split())
124 resource_elements = project_element.getElementsByTagName(
'resource')
125 for resource_element
in resource_elements:
126 if resource_element.parentNode == project_element:
127 self.
resource = str(resource_element.firstChild.data)
132 role_elements = project_element.getElementsByTagName(
'role')
133 for role_element
in role_elements:
134 if role_element.parentNode == project_element:
135 self.
role = str(role_element.firstChild.data)
139 lines_elements = project_element.getElementsByTagName(
'lines')
140 for lines_element
in lines_elements:
141 if lines_element.parentNode == project_element:
142 self.
lines = str(lines_element.firstChild.data)
146 server_elements = project_element.getElementsByTagName(
'server')
147 for server_element
in server_elements:
148 if server_element.parentNode == project_element:
149 self.
server = str(server_element.firstChild.data)
153 site_elements = project_element.getElementsByTagName(
'site')
154 for site_element
in site_elements:
155 if site_element.parentNode == project_element:
156 self.
site = str(site_element.firstChild.data)
157 self.
site =
''.
join(self.site.split())
161 blacklist_elements = project_element.getElementsByTagName(
'blacklist')
162 for blacklist_element
in blacklist_elements:
163 if blacklist_element.parentNode == project_element:
164 self.
blacklist = str(blacklist_element.firstChild.data)
169 cpu_elements = project_element.getElementsByTagName(
'cpu')
170 for cpu_element
in cpu_elements:
171 if cpu_element.parentNode == project_element:
172 self.
cpu = int(cpu_element.firstChild.data)
176 disk_elements = project_element.getElementsByTagName(
'disk')
177 for disk_element
in disk_elements:
178 if disk_element.parentNode == project_element:
179 self.
disk = str(disk_element.firstChild.data)
180 self.
disk =
''.
join(self.disk.split())
184 memory_elements = project_element.getElementsByTagName(
'memory')
185 for memory_element
in memory_elements:
186 if memory_element.parentNode == project_element:
187 self.
memory = int(memory_element.firstChild.data)
191 merge_elements = project_element.getElementsByTagName(
'merge')
192 for merge_element
in merge_elements:
193 if merge_element.parentNode == project_element:
194 if merge_element.firstChild:
195 self.
merge = str(merge_element.firstChild.data)
201 anamerge_elements = project_element.getElementsByTagName(
'anamerge')
202 for anamerge_element
in anamerge_elements:
203 if anamerge_element.parentNode == project_element:
204 if anamerge_element.firstChild:
205 self.
anamerge = str(anamerge_element.firstChild.data)
211 larsoft_elements = project_element.getElementsByTagName(
'larsoft')
216 tag_elements = larsoft_elements[0].getElementsByTagName(
'tag')
217 if tag_elements
and tag_elements[0].firstChild !=
None:
218 self.
release_tag = str(tag_elements[0].firstChild.data)
222 qual_elements = larsoft_elements[0].getElementsByTagName(
'qual')
224 self.
release_qual = str(qual_elements[0].firstChild.data)
229 local_elements = larsoft_elements[0].getElementsByTagName(
'local')
231 local = str(local_elements[0].firstChild.data)
232 if larbatch_posix.isdir(local):
239 version_elements = project_element.getElementsByTagName(
'version')
241 self.
version = str(version_elements[0].firstChild.data)
249 raise IOError(
"Local release directory/tarball %s does not exist." % self.
local_release_tar)
253 file_type_elements = project_element.getElementsByTagName(
'filetype')
254 if file_type_elements:
255 self.
file_type = str(file_type_elements[0].firstChild.data)
259 run_type_elements = project_element.getElementsByTagName(
'runtype')
260 if run_type_elements:
261 self.
run_type = str(run_type_elements[0].firstChild.data)
265 run_number_elements = project_element.getElementsByTagName(
'runnumber')
266 if run_number_elements:
267 self.
run_number = int(run_number_elements[0].firstChild.data)
271 script_elements = project_element.getElementsByTagName(
'script')
272 for script_element
in script_elements:
273 if script_element.parentNode == project_element:
274 self.
script = str(script_element.firstChild.data)
281 jobinfo = subprocess.Popen([
'which', self.
script],
282 stdout=subprocess.PIPE,
283 stderr=subprocess.PIPE)
284 jobout, joberr = jobinfo.communicate()
288 script_path = jobout.splitlines()[0].
strip()
291 if script_path ==
'' or not larbatch_posix.access(script_path, os.X_OK):
292 raise IOError(
'Script %s not found.' % self.
script)
297 worker_validations = project_element.getElementsByTagName(
'check')
298 for worker_validation
in worker_validations:
299 if worker_validation.parentNode == project_element:
304 worker_copys = project_element.getElementsByTagName(
'copy')
305 for worker_copy
in worker_copys:
306 if worker_copy.parentNode == project_element:
307 self.
copy_to_fts = int(worker_copy.firstChild.data)
311 cvmfs_elements = project_element.getElementsByTagName(
'cvmfs')
312 for cvmfs_element
in cvmfs_elements:
313 if cvmfs_element.parentNode == project_element:
314 self.
cvmfs = int(cvmfs_element.firstChild.data)
318 stash_elements = project_element.getElementsByTagName(
'stash')
319 for stash_element
in stash_elements:
320 if stash_element.parentNode == project_element:
321 self.
stash = int(stash_element.firstChild.data)
325 singularity_elements = project_element.getElementsByTagName(
'singularity')
326 for singularity_element
in singularity_elements:
327 if singularity_element.parentNode == project_element:
328 self.
singularity = int(singularity_element.firstChild.data)
332 start_script_elements = project_element.getElementsByTagName(
'startscript')
333 for start_script_element
in start_script_elements:
334 if start_script_element.parentNode == project_element:
335 self.
start_script = str(start_script_element.firstChild.data)
343 jobinfo = subprocess.Popen([
'which', self.
start_script],
344 stdout=subprocess.PIPE,
345 stderr=subprocess.PIPE)
346 jobout, joberr = jobinfo.communicate()
350 script_path = jobout.splitlines()[0].
strip()
357 stop_script_elements = project_element.getElementsByTagName(
'stopscript')
358 for stop_script_element
in stop_script_elements:
359 if stop_script_element.parentNode == project_element:
360 self.
stop_script = str(stop_script_element.firstChild.data)
368 jobinfo = subprocess.Popen([
'which', self.
stop_script],
369 stdout=subprocess.PIPE,
370 stderr=subprocess.PIPE)
371 jobout, joberr = jobinfo.communicate()
375 script_path = jobout.splitlines()[0].
strip()
382 fclpath_elements = project_element.getElementsByTagName(
'fcldir')
383 for fclpath_element
in fclpath_elements:
384 self.fclpath.append(str(fclpath_element.firstChild.data))
388 if check
and 'FHICL_FILE_PATH' in os.environ:
389 for fcldir
in os.environ[
'FHICL_FILE_PATH'].split(
':'):
390 if larbatch_posix.exists(fcldir):
391 self.fclpath.append(fcldir)
397 if not larbatch_posix.exists(fcldir):
398 raise IOError(
"Fcl search directory %s does not exist." % fcldir)
402 stage_elements = project_element.getElementsByTagName(
'stage')
403 default_previous_stage =
''
404 default_input_lists[default_previous_stage] = default_first_input_list
405 for stage_element
in stage_elements:
410 if 'base' in dict(stage_element.attributes):
411 base_name = str(stage_element.attributes[
'base'].firstChild.data)
414 if stage.name == base_name:
418 if base_stage ==
None:
419 raise LookupError(
'Base stage %s not found.' % base_name)
421 self.stages.append(StageDef(stage_element,
424 default_previous_stage,
444 default_previous_stage = self.
stages[-1].name
445 default_input_lists[default_previous_stage] = os.path.join(self.
stages[-1].bookdir,
450 param_elements = project_element.getElementsByTagName(
'parameter')
451 for param_element
in param_elements:
452 name = str(param_element.attributes[
'name'].firstChild.data)
453 value = str(param_element.firstChild.data)