(self, service, action, arguments=None)
| 145 | return dom.getElementsByTagName('NewExternalIPAddress')[0].childNodes[0].data |
| 146 | |
| 147 | def soapRequest(self, service, action, arguments=None): |
| 148 | from xml.dom.minidom import parseString |
| 149 | from debug import logger |
| 150 | conn = httplib.HTTPConnection(self.routerPath.hostname, self.routerPath.port) |
| 151 | conn.request( |
| 152 | 'POST', |
| 153 | self.path, |
| 154 | createRequestXML(service, action, arguments), |
| 155 | { |
| 156 | 'SOAPAction': '"urn:schemas-upnp-org:service:%s#%s"' % (service, action), |
| 157 | 'Content-Type': 'text/xml' |
| 158 | } |
| 159 | ) |
| 160 | resp = conn.getresponse() |
| 161 | conn.close() |
| 162 | if resp.status == 500: |
| 163 | respData = resp.read() |
| 164 | try: |
| 165 | dom = parseString(respData) |
| 166 | errinfo = dom.getElementsByTagName('errorDescription') |
| 167 | if len(errinfo) > 0: |
| 168 | logger.error("UPnP error: %s", respData) |
| 169 | raise UPnPError(errinfo[0].childNodes[0].data) |
| 170 | except: |
| 171 | raise UPnPError("Unable to parse SOAP error: %s" %(respData)) |
| 172 | return resp |
| 173 | |
| 174 | class uPnPThread(threading.Thread, StoppableThread): |
| 175 | SSDP_ADDR = "239.255.255.250" |
no test coverage detected