pax_global_header00006660000000000000000000000064147061413400014512gustar00rootroot0000000000000052 comment=ac8f83ff3330b15bd5b38d993db12783987473ec python-mutesync-0.0.2/000077500000000000000000000000001470614134000146775ustar00rootroot00000000000000python-mutesync-0.0.2/README.md000066400000000000000000000000151470614134000161520ustar00rootroot00000000000000# pymutesync python-mutesync-0.0.2/mutesync/000077500000000000000000000000001470614134000165465ustar00rootroot00000000000000python-mutesync-0.0.2/mutesync/__init__.py000066400000000000000000000027451470614134000206670ustar00rootroot00000000000000from functools import partial import json import logging from typing import Dict import aiohttp import async_timeout _LOGGER = logging.getLogger(__name__) async def authenticate(session: aiohttp.ClientSession, host: str) -> str: """Authenticate and return a token.""" with async_timeout.timeout(10): resp = await session.request( "get", "http://" + host + ":8249/authenticate", data={}, raise_for_status=True, ) data = await resp.json() return data["token"] class PyMutesync: def __init__(self, token, host, session: aiohttp.ClientSession): self.token = token self.host = host self.session = session async def request(self, method, path, data=None) -> Dict: url = f"http://{self.host}:8249/{path}" kwargs = {} if data: if method == "get": kwargs["query"] = data else: kwargs["json"] = data with async_timeout.timeout(10): resp = await self.session.request( method, url, headers={ "Authorization": f"Token {self.token}", "x-mutesync-api-version": "1", }, raise_for_status=True, **kwargs, ) response = await resp.json() return response["data"] async def get_state(self): return await self.request("get", "state") python-mutesync-0.0.2/setup.cfg000066400000000000000000000000461470614134000165200ustar00rootroot00000000000000[egg_info] tag_build = tag_date = 0 python-mutesync-0.0.2/setup.py000066400000000000000000000015211470614134000164100ustar00rootroot00000000000000from setuptools import find_packages, setup long_description = open("README.md").read() setup( name="mutesync", version="0.0.2", license="Apache License 2.0", url="https://github.com/currentoor/pymutesync", author="Karanbir Toor", author_email="support@mutesync.com", description="Asynchronous library to control mutesync devices.", long_description=long_description, long_description_content_type="text/markdown", packages=["mutesync"], zip_safe=True, platforms="any", install_requires=["aiohttp", "async-timeout"], classifiers=[ "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", ], )