mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-28 19:02:34 +00:00
Added deprecation warning for Python2
Removed dependency to google's protobuf in bridge transport Fixed PinRequest handling
This commit is contained in:
parent
6b31ac9753
commit
c71f234a8b
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# This file is part of the TREZOR project.
|
# This file is part of the TREZOR project.
|
||||||
#
|
#
|
||||||
|
@ -27,6 +27,7 @@ import hashlib
|
|||||||
import unicodedata
|
import unicodedata
|
||||||
import json
|
import json
|
||||||
import getpass
|
import getpass
|
||||||
|
import warnings
|
||||||
|
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
|
|
||||||
@ -43,6 +44,9 @@ except NameError:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info.major < 3:
|
||||||
|
warnings.warn("Trezorlib will stop supporting Python2 in next versions.", DeprecationWarning)
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# from PIL import Image
|
# from PIL import Image
|
||||||
# SCREENSHOT = True
|
# SCREENSHOT = True
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from google.protobuf import json_format
|
|
||||||
|
|
||||||
from . import messages
|
from . import messages
|
||||||
from .transport import Transport, TransportException
|
from .transport import Transport, TransportException
|
||||||
@ -99,9 +98,7 @@ class BridgeTransport(Transport):
|
|||||||
|
|
||||||
def write(self, msg):
|
def write(self, msg):
|
||||||
msgname = msg.__class__.__name__
|
msgname = msg.__class__.__name__
|
||||||
msgjson = json_format.MessageToJson(
|
payload = json.dumps({"type": msgname, "message": msg.__dict__})
|
||||||
msg, preserving_proto_field_name=True)
|
|
||||||
payload = '{"type": "%s", "message": %s}' % (msgname, msgjson)
|
|
||||||
r = self.conn.post(
|
r = self.conn.post(
|
||||||
TREZORD_HOST + '/call/%s' % self.session, data=payload)
|
TREZORD_HOST + '/call/%s' % self.session, data=payload)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
@ -114,6 +111,6 @@ class BridgeTransport(Transport):
|
|||||||
raise TransportException('No response stored')
|
raise TransportException('No response stored')
|
||||||
msgtype = getattr(messages, self.response['type'])
|
msgtype = getattr(messages, self.response['type'])
|
||||||
msg = msgtype()
|
msg = msgtype()
|
||||||
msg = json_format.ParseDict(self.response['message'], msg)
|
msg = msg.__dict__.update(json.loads(self.response['message']))
|
||||||
self.response = None
|
self.response = None
|
||||||
return msg
|
return msg
|
||||||
|
Loading…
Reference in New Issue
Block a user