debugging

This commit is contained in:
Jack Robison 2018-10-17 10:05:07 -04:00
parent 0383f05dad
commit 4159779b9d
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
3 changed files with 13 additions and 15 deletions

View file

@ -46,7 +46,7 @@ aioupnp --HOST=239.255.255.250:1900 --MAN=\"ssdp:discover\" --MX=1 --ST=upnp:roo
```
### Commands
add_port_mapping | delete_port_mapping | get_external_ip | get_next_mapping | get_port_mapping_by_index | get_redirects | get_soap_commands | get_specific_port_mapping | m_search
add_port_mapping | delete_port_mapping | get_external_ip | get_next_mapping | get_port_mapping_by_index | get_redirects | debug_gateway | generate_test_data | get_specific_port_mapping | m_search
### Examples

View file

@ -132,13 +132,15 @@ class Gateway:
def debug_gateway(self) -> Dict:
return {
'gateway_address': self.base_ip,
'soap_port': self.port,
'm_search_args': self._m_search_args,
'gateway_descriptor': self.gateway_descriptor(),
'gateway_xml': self._xml_response,
'services_xml': self._service_descriptors,
'services': {service.SCPDURL: service.as_dict() for service in self._services},
'm_search_args': [(k, v) for (k, v) in self._m_search_args.items()],
'reply': self._ok_packet.as_dict(),
'soap_port': self.port,
'registered_soap_commands': self._registered_commands,
'unsupported_soap_commands': self._unsupported_actions,
'gateway_xml': self._xml_response,
'service_descriptors': self._service_descriptors,
'soap_requests': self._soap_requests
}

View file

@ -182,11 +182,11 @@ class UPnP:
return port
@cli
async def get_soap_commands(self) -> Dict:
return {
'supported': list(self.gateway._registered_commands.keys()),
'unsupported': self.gateway._unsupported_actions
}
async def debug_gateway(self) -> str:
return json.dumps({
"gateway": self.gateway.debug_gateway(),
"client_address": self.lan_address,
}, default=_encode, indent=2)
@cli
async def generate_test_data(self):
@ -201,7 +201,6 @@ class UPnP:
print("got redirects:\n%s" % redirects)
except (UPnPError, NotImplementedError):
print("failed to get redirects")
try:
ext_port = await self.get_next_mapping(4567, "UDP", "aioupnp test mapping")
print("set up external mapping to port %i" % ext_port)
@ -217,10 +216,7 @@ class UPnP:
else:
device_path = os.path.join(os.getcwd(), "UNKNOWN GATEWAY")
with open(device_path, "w") as f:
f.write(json.dumps({
"gateway": self.gateway.debug_gateway(),
"client_address": self.lan_address,
}, default=_encode, indent=2))
f.write(await self.debug_gateway())
return "Generated test data! -> %s" % device_path
@classmethod