def _create_nsrs(self, msg_text): """ Given the text from a normalised summary record message, create a list of JobRecord objects and return it. """ msg_text = msg_text.strip() records = msg_text.split('%%') msgs = [] for record in records: # unnecessary hack? if record != '' and not record.isspace(): ns = NormalisedSummaryRecord() ns.load_from_msg(record) msgs.append(ns) return msgs
'EarliestEndTime', 'LatestEndTime', 'WallDuration', 'CpuDuration', 'NormalisedWallDuration', 'NormalisedCpuDuration', 'NumberOfJobs', 'NodeCount', 'Processors'] nodes = {}.fromkeys(tags) data = {} for node in nodes: if node in ('GroupAttribute',): # For these attributes we need to dig into the GroupAttribute # elements to get the values so we save the whole elements. nodes[node] = xml_record.getElementsByTagNameNS( CarParser.NAMESPACE, 'GroupAttribute') else: nodes[node] = xml_record.getElementsByTagNameNS(self.NAMESPACE, node) # Some of the nodes are in the CAR namespace. nodes[node].extend(xml_record.getElementsByTagNameNS(CarParser.NAMESPACE, node)) for field in functions: try: data[field] = functions[field](nodes) except IndexError, e: log.debug('Failed to parse field %s: %s', field, e) except KeyError, e: log.debug('Failed to parse field %s: %s', field, e) nsr = NormalisedSummaryRecord() nsr.set_all(data) return nsr