mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
only support >= 3.6
This commit is contained in:
parent
cc900ae491
commit
190a800e77
@ -2,7 +2,6 @@ sudo: false
|
|||||||
language: python
|
language: python
|
||||||
dist: xenial
|
dist: xenial
|
||||||
python:
|
python:
|
||||||
- "3.5"
|
|
||||||
- "3.6"
|
- "3.6"
|
||||||
- "3.7"
|
- "3.7"
|
||||||
install: pip install tox-travis coveralls
|
install: pip install tox-travis coveralls
|
||||||
|
@ -6,8 +6,8 @@ from pprint import pformat as pf
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
if sys.version_info < (3, 5):
|
if sys.version_info < (3, 6):
|
||||||
print("To use this script you need Python 3.5 or newer! got %s" % sys.version_info)
|
print("To use this script you need Python 3.6 or newer! got %s" % sys.version_info)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
from pyHS100 import SmartPlug # noqa: E402
|
from pyHS100 import SmartPlug # noqa: E402
|
||||||
|
@ -118,7 +118,7 @@ class SmartDevice:
|
|||||||
self.cache = defaultdict(lambda: defaultdict(lambda: None))
|
self.cache = defaultdict(lambda: defaultdict(lambda: None))
|
||||||
self._device_type = DeviceType.Unknown
|
self._device_type = DeviceType.Unknown
|
||||||
self.ioloop = ioloop or asyncio.get_event_loop()
|
self.ioloop = ioloop or asyncio.get_event_loop()
|
||||||
self.sync = SyncSmartDevice(self)
|
self.sync = SyncSmartDevice(self, ioloop=self.ioloop)
|
||||||
|
|
||||||
def _result_from_cache(self, target, cmd) -> Optional[Dict]:
|
def _result_from_cache(self, target, cmd) -> Optional[Dict]:
|
||||||
"""Return query result from cache if still fresh.
|
"""Return query result from cache if still fresh.
|
||||||
@ -606,8 +606,9 @@ class SyncSmartDevice:
|
|||||||
Taken from https://github.com/basnijholt/media_player.kef/
|
Taken from https://github.com/basnijholt/media_player.kef/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, async_device):
|
def __init__(self, async_device, ioloop):
|
||||||
self.async_device = async_device
|
self.async_device = async_device
|
||||||
|
self.ioloop = ioloop
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
method = getattr(self.async_device, attr)
|
method = getattr(self.async_device, attr)
|
||||||
@ -617,7 +618,7 @@ class SyncSmartDevice:
|
|||||||
|
|
||||||
@functools.wraps(method)
|
@functools.wraps(method)
|
||||||
def wrapped(*args, **kwargs):
|
def wrapped(*args, **kwargs):
|
||||||
return asyncio.run(method(*args, **kwargs))
|
return self.ioloop.run_until_complete(method(*args, **kwargs))
|
||||||
|
|
||||||
return wrapped
|
return wrapped
|
||||||
else:
|
else:
|
||||||
|
2
setup.py
2
setup.py
@ -10,7 +10,7 @@ setup(
|
|||||||
license="GPLv3",
|
license="GPLv3",
|
||||||
packages=["pyHS100"],
|
packages=["pyHS100"],
|
||||||
install_requires=["click", "deprecation"],
|
install_requires=["click", "deprecation"],
|
||||||
python_requires=">=3.5",
|
python_requires=">=3.6",
|
||||||
entry_points={"console_scripts": ["pyhs100=pyHS100.cli:cli",],},
|
entry_points={"console_scripts": ["pyhs100=pyHS100.cli:cli",],},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user