mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
only support >= 3.6
This commit is contained in:
parent
cc900ae491
commit
190a800e77
@ -2,7 +2,6 @@ sudo: false
|
||||
language: python
|
||||
dist: xenial
|
||||
python:
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
- "3.7"
|
||||
install: pip install tox-travis coveralls
|
||||
|
@ -6,8 +6,8 @@ from pprint import pformat as pf
|
||||
|
||||
import click
|
||||
|
||||
if sys.version_info < (3, 5):
|
||||
print("To use this script you need Python 3.5 or newer! got %s" % sys.version_info)
|
||||
if sys.version_info < (3, 6):
|
||||
print("To use this script you need Python 3.6 or newer! got %s" % sys.version_info)
|
||||
sys.exit(1)
|
||||
|
||||
from pyHS100 import SmartPlug # noqa: E402
|
||||
|
@ -118,7 +118,7 @@ class SmartDevice:
|
||||
self.cache = defaultdict(lambda: defaultdict(lambda: None))
|
||||
self._device_type = DeviceType.Unknown
|
||||
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]:
|
||||
"""Return query result from cache if still fresh.
|
||||
@ -606,8 +606,9 @@ class SyncSmartDevice:
|
||||
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.ioloop = ioloop
|
||||
|
||||
def __getattr__(self, attr):
|
||||
method = getattr(self.async_device, attr)
|
||||
@ -617,7 +618,7 @@ class SyncSmartDevice:
|
||||
|
||||
@functools.wraps(method)
|
||||
def wrapped(*args, **kwargs):
|
||||
return asyncio.run(method(*args, **kwargs))
|
||||
return self.ioloop.run_until_complete(method(*args, **kwargs))
|
||||
|
||||
return wrapped
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user