python-linkplay 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
linkplay/__main__.py CHANGED
@@ -1,11 +1,11 @@
1
1
  import asyncio
2
2
 
3
3
  from linkplay.controller import LinkPlayController
4
- from linkplay.utils import create_unverified_client_session
4
+ from linkplay.utils import async_create_unverified_client_session
5
5
 
6
6
 
7
7
  async def main():
8
- async with create_unverified_client_session() as session:
8
+ async with await async_create_unverified_client_session() as session:
9
9
  controller = LinkPlayController(session)
10
10
 
11
11
  await controller.discover_bridges()
linkplay/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.0.7'
1
+ __version__ = '0.0.8'
linkplay/utils.py CHANGED
@@ -7,6 +7,7 @@ import ssl
7
7
  from http import HTTPStatus
8
8
  from typing import Dict
9
9
 
10
+ import aiofiles
10
11
  import async_timeout
11
12
  from aiohttp import ClientError, ClientSession, TCPConnector
12
13
  from appdirs import AppDirs
@@ -86,12 +87,25 @@ def create_unverified_context() -> ssl.SSLContext:
86
87
  with open(mtls_certificate_path, "w", encoding="utf-8") as file:
87
88
  file.write(MTLS_CERTIFICATE_CONTENTS)
88
89
 
89
- sslcontext: ssl.SSLContext = ssl.create_default_context(
90
- purpose=ssl.Purpose.SERVER_AUTH
91
- )
92
- sslcontext.load_cert_chain(certfile=mtls_certificate_path)
90
+ return create_ssl_context(path=mtls_certificate_path)
91
+
92
+
93
+ async def async_create_unverified_context() -> ssl.SSLContext:
94
+ """Asynchronously creates an unverified SSL context with the default mTLS certificate."""
95
+ async with aiofiles.tempfile.NamedTemporaryFile(
96
+ "w", encoding="utf-8"
97
+ ) as mtls_certificate:
98
+ await mtls_certificate.write(MTLS_CERTIFICATE_CONTENTS)
99
+ await mtls_certificate.flush()
100
+ return create_ssl_context(path=str(mtls_certificate.name))
101
+
102
+
103
+ def create_ssl_context(path: str) -> ssl.SSLContext:
104
+ """Creates an SSL context from given certificate file."""
105
+ sslcontext: ssl.SSLContext = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
93
106
  sslcontext.check_hostname = False
94
107
  sslcontext.verify_mode = ssl.CERT_NONE
108
+ sslcontext.load_cert_chain(certfile=path)
95
109
  with contextlib.suppress(AttributeError):
96
110
  # This only works for OpenSSL >= 1.0.0
97
111
  sslcontext.options |= ssl.OP_NO_COMPRESSION
@@ -104,3 +118,10 @@ def create_unverified_client_session() -> ClientSession:
104
118
  context: ssl.SSLContext = create_unverified_context()
105
119
  connector: TCPConnector = TCPConnector(family=socket.AF_UNSPEC, ssl=context)
106
120
  return ClientSession(connector=connector)
121
+
122
+
123
+ async def async_create_unverified_client_session() -> ClientSession:
124
+ """Asynchronously creates a ClientSession using the default unverified SSL context"""
125
+ context: ssl.SSLContext = await async_create_unverified_context()
126
+ connector: TCPConnector = TCPConnector(family=socket.AF_UNSPEC, ssl=context)
127
+ return ClientSession(connector=connector)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python_linkplay
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: A Python Library for Seamless LinkPlay Device Control
5
5
  Author: Velleman Group nv
6
6
  License: MIT
@@ -13,6 +13,7 @@ Requires-Dist: aiohttp>=3.8.5
13
13
  Requires-Dist: appdirs>=1.4.4
14
14
  Requires-Dist: async-upnp-client>=0.36.2
15
15
  Requires-Dist: deprecated>=1.2.14
16
+ Requires-Dist: aiofiles>=24.1.0
16
17
  Provides-Extra: testing
17
18
  Requires-Dist: pytest>=7.3.1; extra == "testing"
18
19
  Requires-Dist: pytest-cov>=4.1.0; extra == "testing"
@@ -1,15 +1,15 @@
1
1
  linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
2
- linkplay/__main__.py,sha256=rH3diy9W57N1mw16XeTYkymImeSTIWIaBeB2AGzlL28,559
3
- linkplay/__version__.py,sha256=7EgDv-timUu06OY6bkABnaoin_WSpRfqEKwS3w4SJZ4,22
2
+ linkplay/__main__.py,sha256=Wcza80QaWfOaHjyJEfQYhB9kiPLE0NOqIj4zVWv2Nqs,577
3
+ linkplay/__version__.py,sha256=YQY-i8MemQTvHljd9BqOGgeJEu3FrzurE3TEKDwAax4,22
4
4
  linkplay/bridge.py,sha256=KGD-gwJRhDIdE9jAOUyVlcpfGDb1diDUkggTDvVkf-M,11164
5
5
  linkplay/consts.py,sha256=wz1lVRz-9hkymc9ucV_LHldcu-msYvimI0tjr2Ncgoc,12734
6
6
  linkplay/controller.py,sha256=JIQAKPs3EK7ZwzoyzSy0HBl21gH9Cc9RrLXIGOMzkCM,2146
7
7
  linkplay/discovery.py,sha256=aEzN_94pKLmHKYIL7DxSW0FYRsaF2ruZe2bwXz0zf5U,4299
8
8
  linkplay/endpoint.py,sha256=qbB977_KltNRZlWlm-3JiByPZiie84Hn2TL523IfqGs,1486
9
9
  linkplay/exceptions.py,sha256=tWJWHsKVkUEq3Yet1Z739IxcaQT8YamDeSp0tqHde9c,107
10
- linkplay/utils.py,sha256=IdUtceKTA3vdY_HNzKUFZzPGXkQFW8E4yUNe5K9TNbo,3583
11
- python_linkplay-0.0.7.dist-info/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
12
- python_linkplay-0.0.7.dist-info/METADATA,sha256=VCLgUHUz00tc0tLzAiOpMkPDeIbrHDfkYrItjH8VZXA,2955
13
- python_linkplay-0.0.7.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
14
- python_linkplay-0.0.7.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
15
- python_linkplay-0.0.7.dist-info/RECORD,,
10
+ linkplay/utils.py,sha256=gEFrajQHejetKaVpYWxkZLn7Nh4W3PaQSknDMU2eKIU,4520
11
+ python_linkplay-0.0.8.dist-info/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
12
+ python_linkplay-0.0.8.dist-info/METADATA,sha256=IAO7Ix1g0elKKcDGjYpXlrTx1bDfb9vMnitiAOdgWcA,2987
13
+ python_linkplay-0.0.8.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
14
+ python_linkplay-0.0.8.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
15
+ python_linkplay-0.0.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5