add zipped_debugging_info

This commit is contained in:
Jack Robison 2018-10-18 15:10:46 -04:00
parent 268f20708e
commit 336c51e6fc
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,4 @@
__version__ = "0.0.2a8" __version__ = "0.0.2a9"
__name__ = "aioupnp" __name__ = "aioupnp"
__author__ = "Jack Robison" __author__ = "Jack Robison"
__maintainer__ = "Jack Robison" __maintainer__ = "Jack Robison"

View file

@ -3,6 +3,8 @@ import socket
import logging import logging
import json import json
import asyncio import asyncio
import zlib
import base64
from collections import OrderedDict from collections import OrderedDict
from typing import Tuple, Dict, List, Union from typing import Tuple, Dict, List, Union
from aioupnp.fault import UPnPError from aioupnp.fault import UPnPError
@ -187,6 +189,15 @@ class UPnP:
"client_address": self.lan_address, "client_address": self.lan_address,
}, default=_encode, indent=2) }, default=_encode, indent=2)
@property
def zipped_debugging_info(self) -> str:
return base64.b64encode(zlib.compress(
json.dumps({
"gateway": self.gateway.debug_gateway(),
"client_address": self.lan_address,
}, default=_encode, indent=2).encode()
)).decode()
@cli @cli
async def generate_test_data(self): async def generate_test_data(self):
print("found gateway via M-SEARCH") print("found gateway via M-SEARCH")