Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for the API change of construct v2.9.30 #220

Merged
merged 3 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions miio/chuangmi_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ def play(self, command: str):


class ProntoPulseAdapter(Adapter):
def _decode(self, obj, context):
def _decode(self, obj, context, *args, **kwargs):
return int(obj * context._.modulation_period)

def _encode(self, obj, context):
def _encode(self, obj, context, *args, **kwargs):
raise RuntimeError('Not implemented')


Expand Down
8 changes: 4 additions & 4 deletions miio/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,24 @@ def is_hello(x) -> bool:

class TimeAdapter(Adapter):
"""Adapter for timestamp conversion."""
def _encode(self, obj, context):
def _encode(self, obj, context, *args, **kwargs):
return calendar.timegm(obj.timetuple())

def _decode(self, obj, context):
def _decode(self, obj, context, *args, **kwargs):
return datetime.datetime.utcfromtimestamp(obj)


class EncryptionAdapter(Adapter):
"""Adapter to handle communication encryption."""
def _encode(self, obj, context):
def _encode(self, obj, context, *args, **kwargs):
"""Encrypt the given payload with the token stored in the context.

:param obj: JSON object to encrypt"""
# pp(context)
return Utils.encrypt(json.dumps(obj).encode('utf-8') + b'\x00',
context['_']['token'])

def _decode(self, obj, context):
def _decode(self, obj, context, *args, **kwargs):
"""Decrypts the given payload with the token stored in the context.

:return str: JSON object"""
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
click
cryptography
pretty_cron
construct>=2.9.23
construct>=2.9.23,<=2.9.30
zeroconf
attrs
typing # for py3.4 support
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def readme():
packages=["miio", "mirobo"],

python_requires='>=3.4',
install_requires=['construct>=2.9.23',
install_requires=['construct>=2.9.23,<=2.9.30',
'click',
'cryptography',
'pretty_cron',
Expand Down