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 ### 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 ### Examples

View file

@ -132,13 +132,15 @@ class Gateway:
def debug_gateway(self) -> Dict: def debug_gateway(self) -> Dict:
return { return {
'gateway_address': self.base_ip, 'gateway_address': self.base_ip,
'soap_port': self.port, 'gateway_descriptor': self.gateway_descriptor(),
'm_search_args': self._m_search_args, '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(), 'reply': self._ok_packet.as_dict(),
'soap_port': self.port,
'registered_soap_commands': self._registered_commands, 'registered_soap_commands': self._registered_commands,
'unsupported_soap_commands': self._unsupported_actions, 'unsupported_soap_commands': self._unsupported_actions,
'gateway_xml': self._xml_response,
'service_descriptors': self._service_descriptors,
'soap_requests': self._soap_requests 'soap_requests': self._soap_requests
} }

View file

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