mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +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.
|
||||
#
|
||||
|
@ -27,6 +27,7 @@ import hashlib
|
||||
import unicodedata
|
||||
import json
|
||||
import getpass
|
||||
import warnings
|
||||
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
@ -43,6 +44,9 @@ except NameError:
|
||||
pass
|
||||
|
||||
|
||||
if sys.version_info.major < 3:
|
||||
warnings.warn("Trezorlib will stop supporting Python2 in next versions.", DeprecationWarning)
|
||||
|
||||
# try:
|
||||
# from PIL import Image
|
||||
# SCREENSHOT = True
|
||||
|
@ -20,7 +20,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import requests
|
||||
from google.protobuf import json_format
|
||||
|
||||
from . import messages
|
||||
from .transport import Transport, TransportException
|
||||
@ -99,9 +98,7 @@ class BridgeTransport(Transport):
|
||||
|
||||
def write(self, msg):
|
||||
msgname = msg.__class__.__name__
|
||||
msgjson = json_format.MessageToJson(
|
||||
msg, preserving_proto_field_name=True)
|
||||
payload = '{"type": "%s", "message": %s}' % (msgname, msgjson)
|
||||
payload = json.dumps({"type": msgname, "message": msg.__dict__})
|
||||
r = self.conn.post(
|
||||
TREZORD_HOST + '/call/%s' % self.session, data=payload)
|
||||
if r.status_code != 200:
|
||||
@ -114,6 +111,6 @@ class BridgeTransport(Transport):
|
||||
raise TransportException('No response stored')
|
||||
msgtype = getattr(messages, self.response['type'])
|
||||
msg = msgtype()
|
||||
msg = json_format.ParseDict(self.response['message'], msg)
|
||||
msg = msg.__dict__.update(json.loads(self.response['message']))
|
||||
self.response = None
|
||||
return msg
|
||||
|
Loading…
Reference in New Issue
Block a user