mypy
This commit is contained in:
parent
903041b5f6
commit
52ac73bf57
4 changed files with 12 additions and 9 deletions
|
@ -171,8 +171,8 @@ async def multi_m_search(lan_address: str, gateway_address: str, timeout: int =
|
|||
protocol, gateway_address, lan_address = await listen_ssdp(
|
||||
lan_address, gateway_address, loop
|
||||
)
|
||||
fut = asyncio.ensure_future(protocol.send_m_searches(
|
||||
fut = protocol.send_m_searches(
|
||||
address=gateway_address, datagrams=list(packet_generator())
|
||||
), loop=loop)
|
||||
)
|
||||
loop.call_later(timeout, lambda: None if not fut or fut.done() else fut.cancel())
|
||||
return protocol
|
||||
|
|
|
@ -39,7 +39,7 @@ def serialize_scpd_get(path: str, address: str) -> bytes:
|
|||
|
||||
def deserialize_scpd_get_response(content: bytes) -> Dict[str, Any]:
|
||||
if XML_VERSION_PREFIX.encode() in content:
|
||||
parsed: List[Tuple[bytes, bytes]] = CONTENT_PATTERN.findall(content.decode())
|
||||
parsed: List[Tuple[str, str]] = CONTENT_PATTERN.findall(content.decode())
|
||||
xml_dict = xml_to_dict('' if not parsed else parsed[0][0])
|
||||
return parse_device_dict(xml_dict)
|
||||
return {}
|
||||
|
|
|
@ -260,15 +260,18 @@ class UPnP:
|
|||
await self.get_redirects()
|
||||
except UPnPError:
|
||||
pass
|
||||
external_port = 0
|
||||
made_mapping = False
|
||||
try:
|
||||
external_port = await self.get_next_mapping(1234, 'TCP', 'aioupnp testing')
|
||||
made_mapping = True
|
||||
except UPnPError:
|
||||
external_port = None
|
||||
pass
|
||||
try:
|
||||
await self.get_redirects()
|
||||
except UPnPError:
|
||||
pass
|
||||
if external_port:
|
||||
if made_mapping:
|
||||
try:
|
||||
await self.delete_port_mapping(external_port, 'TCP')
|
||||
except UPnPError:
|
||||
|
|
|
@ -2,7 +2,7 @@ import unittest
|
|||
from aioupnp.device import CaseInsensitive
|
||||
|
||||
|
||||
class TestService(CaseInsensitive):
|
||||
class _TestService(CaseInsensitive):
|
||||
serviceType = None
|
||||
serviceId = None
|
||||
controlURL = None
|
||||
|
@ -12,14 +12,14 @@ class TestService(CaseInsensitive):
|
|||
|
||||
class TestCaseInsensitive(unittest.TestCase):
|
||||
def test_initialize(self):
|
||||
s = TestService(
|
||||
s = _TestService(
|
||||
serviceType="test", serviceId="test id", controlURL="/test", eventSubURL="/test2", SCPDURL="/test3"
|
||||
)
|
||||
self.assertEqual('test', getattr(s, 'serviceType'))
|
||||
self.assertEqual('test', getattr(s, 'servicetype'))
|
||||
self.assertEqual('test', getattr(s, 'SERVICETYPE'))
|
||||
|
||||
s = TestService(
|
||||
s = _TestService(
|
||||
servicetype="test", serviceid="test id", controlURL="/test", eventSubURL="/test2", SCPDURL="/test3"
|
||||
)
|
||||
self.assertEqual('test', getattr(s, 'serviceType'))
|
||||
|
@ -35,7 +35,7 @@ class TestCaseInsensitive(unittest.TestCase):
|
|||
}, s.as_dict())
|
||||
|
||||
def test_set_attr(self):
|
||||
s = TestService(
|
||||
s = _TestService(
|
||||
serviceType="test", serviceId="test id", controlURL="/test", eventSubURL="/test2", SCPDURL="/test3"
|
||||
)
|
||||
self.assertEqual('test', getattr(s, 'serviceType'))
|
||||
|
|
Loading…
Reference in a new issue