def _submit(self, method, response=None, raw=False): "Constructs and submits the final SOAP message" global GSX_SESSION root = ET.SubElement(self.body, self.obj._namespace + method) if method is "Authenticate": root.append(self.data) else: request_name = method + "Request" request = ET.SubElement(root, request_name) request.append(GSX_SESSION) if self._request == request_name: # Some requests lack a top-level container request.extend(self.data) else: request.append(self.data) data = ET.tostring(self.env, "UTF-8") res = self._send(method, data) xml = res.read() if res.status > 200: raise GsxError(xml=xml, url=self._url) logging.debug("Response: %s %s %s" % (res.status, res.reason, xml)) response = response or self._response self.objects = objectify.parse(xml, response) return self.objects
def _submit(self, method, response=None, raw=False): "Constructs and submits the final SOAP message" root = ET.SubElement(self.body, self.obj._namespace + method) if method is "Authenticate": root.append(self.data) else: request_name = method + "Request" # @hack for Reported Symptom/Issue API which nests two ReportedSymptomIssueRequest elements if method.endswith("Request"): request_name = method # @hack FetchDiagnosticDetails doesn't follow the naming conventions if method.endswith('FetchDiagnosticDetails'): request_name = 'FetchDiagnosticDetailsRequestData' # @hack FetchDiagnosticSuites doesn't follow the naming conventions if method.endswith('FetchDiagnosticSuites'): request_name = 'FetchDiagnosticSuitesRequestData' # @hack RunDiagnosticTest doesn't follow the naming conventions if method.endswith('RunDiagnosticTest'): request_name = 'RunDiagnosticTestRequestData' request = ET.SubElement(root, request_name) request.append(GSX_SESSION) if self._request == request_name: # Some requests lack a top-level container request.extend(self.data) else: request.append(self.data) data = ET.tostring(self.env, "UTF-8") res = self._send(method, data) xml = res.text.encode('utf-8') self.xml_response = xml logging.debug("Response: %s %s %s" % (res.status_code, res.reason, xml)) if res.status_code > 200: raise GsxError(xml=xml, url=self._url, status=res.status_code) if raw is True: return ET.fromstring(self.xml_response) response = response or self._response self.objects = objectify.parse(xml, response) return self.objects
def __init__(self, http_response, xml, el_method, el_response, raw=False): self.result = None # result status self.response = None # objectified result self.el_method = el_method self.el_response = el_response if http_response.status_code > 200: raise GsxError(xml=xml, url=self._url) self.response = objectify.parse(xml, self.el_response) logging.debug("Response: %s %s %s" % (http_response.status_code, http_response.reason, xml)) if raw is True: return ET.fromstring(self.xml_response) if hasattr(self.response, 'outCome'): self.result = self.response.outCome if self.result == 'STOP': raise GsxError(message=self.response.messages, code=self.result)
def setParametersFromXML(self, params) -> dict: """ """ import objectify root = self.get_root() if root.tag != 'project': raise ValueError for child in root: kind = child.attrib print(f'child tag is {child.tag}: {kind}') print([elem.tag for elem in root.iter()]) systems = {} for system in root.iter('system'): attributes = system.attrib name = dict(attributes['title']) #name, status=attributes['title'], attributes['complete'] systems.update(name) print(systems) for description in root.iter('description'): print(description.text) for system in root.findall( "./kind/interaction/system/[protein='CalB']"): print(system.attrib) project = objectify.parse(path_file) return project