mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
fix pylint warnings
This commit is contained in:
parent
cbbd7004a8
commit
3a108ee8a5
@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import binascii
|
||||
import hashlib
|
||||
import mnemonic
|
||||
|
||||
__doc__ = '''
|
||||
Use this script to cross-check that TREZOR generated valid
|
||||
@ -13,10 +16,6 @@ __doc__ = '''
|
||||
without an internet connection).
|
||||
'''
|
||||
|
||||
import binascii
|
||||
import hashlib
|
||||
import mnemonic
|
||||
|
||||
# Python2 vs Python3
|
||||
try:
|
||||
input = raw_input
|
||||
|
@ -1,10 +1,9 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import config
|
||||
|
||||
from trezorlib.client import TrezorDebugClient
|
||||
from trezorlib.tx_api import TXAPIBitcoin
|
||||
import config
|
||||
|
||||
class TrezorTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
10
trezorctl
10
trezorctl
@ -80,7 +80,7 @@ def get_transport(transport_string, path, **kwargs):
|
||||
from trezorlib.transport_fake import FakeTransport
|
||||
return FakeTransport(path, **kwargs)
|
||||
|
||||
raise NotImplemented("Unknown transport")
|
||||
raise NotImplementedError("Unknown transport")
|
||||
|
||||
class Commands(object):
|
||||
def __init__(self, client):
|
||||
@ -159,11 +159,13 @@ class Commands(object):
|
||||
if args.mnemonic:
|
||||
mnemonic = ' '.join(args.mnemonic)
|
||||
return self.client.load_device_by_mnemonic(mnemonic, args.pin,
|
||||
args.passphrase_protection, args.label, 'english', args.skip_checksum)
|
||||
|
||||
args.passphrase_protection,
|
||||
args.label, 'english',
|
||||
args.skip_checksum)
|
||||
else:
|
||||
return self.client.load_device_by_xprv(args.xprv, args.pin,
|
||||
args.passphrase_protection, args.label, 'english')
|
||||
args.passphrase_protection,
|
||||
args.label, 'english')
|
||||
|
||||
def reset_device(self, args):
|
||||
return self.client.reset_device(True, args.strength, args.passphrase_protection,
|
||||
|
@ -37,15 +37,14 @@ Provide serialization and de-serialization of Google's protobuf Messages into/fr
|
||||
# Note that preservation of unknown fields is currently not available for Python (c) google docs
|
||||
# extensions is not supported from 0.0.5 (due to gpb2.3 changes)
|
||||
|
||||
__version__='0.0.5'
|
||||
__author__='Paul Dovbush <dpp@dpp.su>'
|
||||
|
||||
|
||||
import json
|
||||
from google.protobuf.descriptor import FieldDescriptor as FD
|
||||
import binascii
|
||||
from . import types_pb2 as types
|
||||
|
||||
__version__ = '0.0.5'
|
||||
__author__ = 'Paul Dovbush <dpp@dpp.su>'
|
||||
|
||||
class ParseError(Exception): pass
|
||||
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import math
|
||||
import operator
|
||||
from PyQt4.QtGui import (QPushButton, QLineEdit, QSizePolicy, QRegExpValidator, QLabel,
|
||||
QApplication, QWidget, QGridLayout, QVBoxLayout, QHBoxLayout)
|
||||
from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt
|
||||
|
@ -77,7 +77,7 @@ class Transport(object):
|
||||
return None
|
||||
|
||||
data = self._read()
|
||||
if data == None:
|
||||
if data is None:
|
||||
return None
|
||||
|
||||
return self._parse_message(data)
|
||||
|
@ -1,9 +1,8 @@
|
||||
'''BridgeTransport implements transport TREZOR Bridge (aka trezord).'''
|
||||
|
||||
import requests
|
||||
import json
|
||||
import requests
|
||||
from . import protobuf_json
|
||||
from . import mapping
|
||||
from . import messages_pb2 as proto
|
||||
from .transport import Transport
|
||||
|
||||
@ -21,7 +20,7 @@ class BridgeTransport(Transport):
|
||||
|
||||
self.session = None
|
||||
self.response = None
|
||||
self.conn = requests.Session();
|
||||
self.conn = requests.Session()
|
||||
|
||||
super(BridgeTransport, self).__init__(device, *args, **kwargs)
|
||||
|
||||
@ -81,7 +80,7 @@ class BridgeTransport(Transport):
|
||||
self.response = r.json()
|
||||
|
||||
def _read(self):
|
||||
if self.response == None:
|
||||
if self.response is None:
|
||||
raise Exception('No response stored')
|
||||
cls = getattr(proto, self.response['type'])
|
||||
inst = cls()
|
||||
|
@ -1,12 +1,11 @@
|
||||
from __future__ import print_function
|
||||
|
||||
'''PipeTransport implements fake wire transport over local named pipe.
|
||||
Use this transport for talking with trezor simulator.'''
|
||||
|
||||
import os
|
||||
from select import select
|
||||
from .transport import Transport
|
||||
|
||||
"""PipeTransport implements fake wire transport over local named pipe.
|
||||
Use this transport for talking with trezor simulator."""
|
||||
|
||||
class PipeTransport(Transport):
|
||||
def __init__(self, device, is_device, *args, **kwargs):
|
||||
self.is_device = is_device # Set True if act as device
|
||||
|
@ -4,8 +4,8 @@ from __future__ import print_function
|
||||
|
||||
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
|
||||
|
||||
import serial
|
||||
from select import select
|
||||
import serial
|
||||
from .transport import Transport
|
||||
|
||||
class SerialTransport(Transport):
|
||||
|
@ -1,17 +1,19 @@
|
||||
import binascii
|
||||
import json
|
||||
from decimal import Decimal
|
||||
# from filecache import filecache, DAY
|
||||
from . import types_pb2 as proto_types
|
||||
import requests
|
||||
from . import types_pb2 as proto_types
|
||||
|
||||
def fetch_json(url):
|
||||
try:
|
||||
r = requests.get(url, headers={'User-agent': 'Mozilla/5.0'})
|
||||
return r.json()
|
||||
except:
|
||||
raise Exception('URL error: %s' % url)
|
||||
|
||||
def insight_tx(url, rawdata=False):
|
||||
if not rawdata:
|
||||
try:
|
||||
r = requests.get(url, headers = {'User-agent': 'Mozilla/5.0'})
|
||||
data = r.json()
|
||||
except:
|
||||
raise Exception('URL error: %s' % url)
|
||||
data = fetch_json(url)
|
||||
else:
|
||||
data = url
|
||||
|
||||
@ -42,11 +44,7 @@ def insight_tx(url, rawdata=False):
|
||||
|
||||
def smartbit_tx(url, rawdata=False):
|
||||
if not rawdata:
|
||||
try:
|
||||
r = requests.get(url, headers = {'User-agent': 'Mozilla/5.0'})
|
||||
data = r.json()
|
||||
except:
|
||||
raise Exception('URL error: %s' % url)
|
||||
data = fetch_json(url)
|
||||
else:
|
||||
data = url
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user