Skip to content

Commit a675ef0

Browse files
syssirytilahti
authored andcommitted
Fixes for the API change of construct v2.9.30 (#220)
* Fixes for the API change of construct v2.9.30. construct==2.9.30 pinned. * Backward compatible solution used. * Range of compatible construct versions added.
1 parent bc9fdcf commit a675ef0

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

miio/chuangmi_ir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def play(self, command: str):
130130

131131

132132
class ProntoPulseAdapter(Adapter):
133-
def _decode(self, obj, context):
133+
def _decode(self, obj, context, *args, **kwargs):
134134
return int(obj * context._.modulation_period)
135135

136-
def _encode(self, obj, context):
136+
def _encode(self, obj, context, *args, **kwargs):
137137
raise RuntimeError('Not implemented')
138138

139139

miio/protocol.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,24 @@ def is_hello(x) -> bool:
130130

131131
class TimeAdapter(Adapter):
132132
"""Adapter for timestamp conversion."""
133-
def _encode(self, obj, context):
133+
def _encode(self, obj, context, *args, **kwargs):
134134
return calendar.timegm(obj.timetuple())
135135

136-
def _decode(self, obj, context):
136+
def _decode(self, obj, context, *args, **kwargs):
137137
return datetime.datetime.utcfromtimestamp(obj)
138138

139139

140140
class EncryptionAdapter(Adapter):
141141
"""Adapter to handle communication encryption."""
142-
def _encode(self, obj, context):
142+
def _encode(self, obj, context, *args, **kwargs):
143143
"""Encrypt the given payload with the token stored in the context.
144144
145145
:param obj: JSON object to encrypt"""
146146
# pp(context)
147147
return Utils.encrypt(json.dumps(obj).encode('utf-8') + b'\x00',
148148
context['_']['token'])
149149

150-
def _decode(self, obj, context):
150+
def _decode(self, obj, context, *args, **kwargs):
151151
"""Decrypts the given payload with the token stored in the context.
152152
153153
:return str: JSON object"""

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
click
22
cryptography
33
pretty_cron
4-
construct>=2.9.23
4+
construct>=2.9.23,<=2.9.30
55
zeroconf
66
attrs
77
typing # for py3.4 support

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def readme():
4242
packages=["miio", "mirobo"],
4343

4444
python_requires='>=3.4',
45-
install_requires=['construct>=2.9.23',
45+
install_requires=['construct>=2.9.23,<=2.9.30',
4646
'click',
4747
'cryptography',
4848
'pretty_cron',

0 commit comments

Comments
 (0)