add gather_debug_info command #24

Merged
jackrobison merged 2 commits from debug-gateway into master 2020-10-13 21:57:17 +02:00
Showing only changes of commit dc80dedff9 - Show all commits

View file

@ -13,14 +13,6 @@ from aioupnp.commands import GetGenericPortMappingEntryResponse, GetSpecificPort
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def _encode(x):
if isinstance(x, bytes):
return x.decode()
elif isinstance(x, Exception):
return str(x)
return x
class UPnP: class UPnP:
def __init__(self, lan_address: str, gateway_address: str, gateway: Gateway) -> None: def __init__(self, lan_address: str, gateway_address: str, gateway: Gateway) -> None:
self.lan_address = lan_address self.lan_address = lan_address
@ -246,13 +238,20 @@ class UPnP:
await self.add_port_mapping(port, protocol, _internal_port, self.lan_address, description) await self.add_port_mapping(port, protocol, _internal_port, self.lan_address, description)
return port return port
async def gather_debug_info(self) -> str: async def gather_debug_info(self) -> str: # pragma: no cover
""" """
Gather debugging information for this gateway, used for generating test cases for devices with errors. Gather debugging information for this gateway, used for generating test cases for devices with errors.
:return: (str) compressed debugging information :return: (str) compressed debugging information
""" """
def _encode(x):
if isinstance(x, bytes):
return x.decode()
elif isinstance(x, Exception):
return str(x)
return x
try: try:
await self.get_external_ip() await self.get_external_ip()
except UPnPError: except UPnPError: