From 74e9bedaea718340a019b3dfbc846577832c43da Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Wed, 14 Feb 2018 08:17:55 +0100 Subject: [PATCH] Use the path parameter of encode/decode again to be future-proof. --- miio/chuangmi_ir.py | 4 ++-- miio/protocol.py | 8 ++++---- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/miio/chuangmi_ir.py b/miio/chuangmi_ir.py index ab2a6431a..3b46c828c 100644 --- a/miio/chuangmi_ir.py +++ b/miio/chuangmi_ir.py @@ -130,10 +130,10 @@ def play(self, command: str): class ProntoPulseAdapter(Adapter): - def _decode(self, obj, context, *args, **kwargs): + def _decode(self, obj, context, path): return int(obj * context._.modulation_period) - def _encode(self, obj, context, *args, **kwargs): + def _encode(self, obj, context, path): raise RuntimeError('Not implemented') diff --git a/miio/protocol.py b/miio/protocol.py index 9d1d862d5..e9704fbef 100644 --- a/miio/protocol.py +++ b/miio/protocol.py @@ -130,16 +130,16 @@ def is_hello(x) -> bool: class TimeAdapter(Adapter): """Adapter for timestamp conversion.""" - def _encode(self, obj, context, *args, **kwargs): + def _encode(self, obj, context, path): return calendar.timegm(obj.timetuple()) - def _decode(self, obj, context, *args, **kwargs): + def _decode(self, obj, context, path): return datetime.datetime.utcfromtimestamp(obj) class EncryptionAdapter(Adapter): """Adapter to handle communication encryption.""" - def _encode(self, obj, context, *args, **kwargs): + def _encode(self, obj, context, path): """Encrypt the given payload with the token stored in the context. :param obj: JSON object to encrypt""" @@ -147,7 +147,7 @@ def _encode(self, obj, context, *args, **kwargs): return Utils.encrypt(json.dumps(obj).encode('utf-8') + b'\x00', context['_']['token']) - def _decode(self, obj, context, *args, **kwargs): + def _decode(self, obj, context, path): """Decrypts the given payload with the token stored in the context. :return str: JSON object""" diff --git a/requirements.txt b/requirements.txt index 7b27ea3de..5aa76b10a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ click cryptography pretty_cron -construct>=2.9.23,<=2.9.30 +construct==2.9.30 zeroconf attrs typing # for py3.4 support diff --git a/setup.py b/setup.py index dd4e28af0..814c8a383 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ def readme(): packages=["miio", "mirobo"], python_requires='>=3.4', - install_requires=['construct>=2.9.23,<=2.9.30', + install_requires=['construct==2.9.30', 'click', 'cryptography', 'pretty_cron',