From 190a800e77adef7ef9b9216a7ef828bc0df393d4 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 11 Nov 2019 23:15:57 +0100 Subject: [PATCH] only support >= 3.6 --- .travis.yml | 1 - pyHS100/cli.py | 4 ++-- pyHS100/smartdevice.py | 7 ++++--- setup.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36742c76..37eeb8d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python dist: xenial python: - - "3.5" - "3.6" - "3.7" install: pip install tox-travis coveralls diff --git a/pyHS100/cli.py b/pyHS100/cli.py index 0bb59500..4fd58952 100755 --- a/pyHS100/cli.py +++ b/pyHS100/cli.py @@ -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 diff --git a/pyHS100/smartdevice.py b/pyHS100/smartdevice.py index 7aa5b8df..8b770a08 100755 --- a/pyHS100/smartdevice.py +++ b/pyHS100/smartdevice.py @@ -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: diff --git a/setup.py b/setup.py index bfac5ea0..a5da4333 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( license="GPLv3", packages=["pyHS100"], install_requires=["click", "deprecation"], - python_requires=">=3.5", + python_requires=">=3.6", entry_points={"console_scripts": ["pyhs100=pyHS100.cli:cli",],}, zip_safe=False, )