Beispiel #1
0
 def __init__(self, request, response, error_code, error_desc = None):
     super(UPnPError, self).__init__(request, response, 500)
     if error_desc is None:
         error_desc = self._error_descs.get(error_code, "Unknown")
     result = Element(QName(ns_soap_env, "Fault"))
     SubElement(result, QName(ns_soap_env, "faultcode")).text \
         = str(QName(ns_soap_env, "Client"))
     SubElement(result, QName(ns_soap_env, "faultstring")).text \
         = "UPnPError"
     detail = SubElement(result, "detail")
     upnp_error = SubElement(detail, QName(UPNP_CONTROL_NS, "UPnPError"))
     SubElement(upnp_error, QName(UPNP_CONTROL_NS, "errorCode")).text \
         = str(error_code)
     SubElement(upnp_error, QName(UPNP_CONTROL_NS, "errorDescription")) \
         .text = error_desc
     self._fault = buildSoapResponse(self.response, result)
Beispiel #2
0
 def __init__(self, request, response, error_code, error_desc=None):
     super(UPnPError, self).__init__(request, response, 500)
     if error_desc is None:
         error_desc = self._error_descs.get(error_code, "Unknown")
     result = Element(QName(ns_soap_env, "Fault"))
     SubElement(result, QName(ns_soap_env, "faultcode")).text \
         = str(QName(ns_soap_env, "Client"))
     SubElement(result, QName(ns_soap_env, "faultstring")).text \
         = "UPnPError"
     detail = SubElement(result, "detail")
     upnp_error = SubElement(detail, QName(UPNP_CONTROL_NS, "UPnPError"))
     SubElement(upnp_error, QName(UPNP_CONTROL_NS, "errorCode")).text \
         = str(error_code)
     SubElement(upnp_error, QName(UPNP_CONTROL_NS, "errorDescription")) \
         .text = error_desc
     self._fault = buildSoapResponse(self.response, result)
Beispiel #3
0
 def _control(self, *args):
     payload = parseSoapRequest(self.request)[2]
     action_ns, action = splitQTag(payload.tag)
     action_args = dict()
     for node in payload:
         action_args[node.tag] = node.text
     method = getattr(self, action, None)
     if method is None or not getattr(method, "_is_upnp_service", False):
         self.fire(Log(logging.INFO, 'Action ' + action 
                       + " not implemented"), "logger")
         return UPnPError(self.request, self.response, 401)
     try:
         out_args = method(**action_args)
     except UPnPServiceError as error:
         return UPnPError(self.request, self.response, error.code)
     result = Element("{%s}%sResponse" % (action_ns, action))
     for name, value in out_args:
         arg = SubElement(result, name)
         arg.text = str(value)
     return buildSoapResponse(self.response, result)
Beispiel #4
0
 def _control(self, *args):
     payload = parseSoapRequest(self.request)[2]
     action_ns, action = splitQTag(payload.tag)
     action_args = dict()
     for node in payload:
         action_args[node.tag] = node.text
     method = getattr(self, action, None)
     if method is None or not getattr(method, "_is_upnp_service", False):
         self.fire(log(logging.INFO, 'Action ' + action 
                       + " not implemented"), "logger")
         return UPnPError(self.request, self.response, 401)
     try:
         out_args = method(**action_args)
     except UPnPServiceError as error:
         return UPnPError(self.request, self.response, error.code)
     result = Element("{%s}%sResponse" % (action_ns, action))
     for name, value in out_args:
         arg = SubElement(result, name)
         arg.text = unicode(value)
     return buildSoapResponse(self.response, result)