fix pylint warnings

pull/1/head
Pavol Rusnak 8 years ago
parent cbbd7004a8
commit 3a108ee8a5
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -1,5 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function from __future__ import print_function
import binascii
import hashlib
import mnemonic
__doc__ = ''' __doc__ = '''
Use this script to cross-check that TREZOR generated valid Use this script to cross-check that TREZOR generated valid
@ -13,10 +16,6 @@ __doc__ = '''
without an internet connection). without an internet connection).
''' '''
import binascii
import hashlib
import mnemonic
# Python2 vs Python3 # Python2 vs Python3
try: try:
input = raw_input input = raw_input

@ -1,10 +1,9 @@
from __future__ import print_function from __future__ import print_function
import unittest import unittest
import config
from trezorlib.client import TrezorDebugClient from trezorlib.client import TrezorDebugClient
from trezorlib.tx_api import TXAPIBitcoin from trezorlib.tx_api import TXAPIBitcoin
import config
class TrezorTest(unittest.TestCase): class TrezorTest(unittest.TestCase):
def setUp(self): def setUp(self):

@ -80,7 +80,7 @@ def get_transport(transport_string, path, **kwargs):
from trezorlib.transport_fake import FakeTransport from trezorlib.transport_fake import FakeTransport
return FakeTransport(path, **kwargs) return FakeTransport(path, **kwargs)
raise NotImplemented("Unknown transport") raise NotImplementedError("Unknown transport")
class Commands(object): class Commands(object):
def __init__(self, client): def __init__(self, client):
@ -159,11 +159,13 @@ class Commands(object):
if args.mnemonic: if args.mnemonic:
mnemonic = ' '.join(args.mnemonic) mnemonic = ' '.join(args.mnemonic)
return self.client.load_device_by_mnemonic(mnemonic, args.pin, 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: else:
return self.client.load_device_by_xprv(args.xprv, args.pin, 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): def reset_device(self, args):
return self.client.reset_device(True, args.strength, args.passphrase_protection, 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 # 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) # 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 import json
from google.protobuf.descriptor import FieldDescriptor as FD from google.protobuf.descriptor import FieldDescriptor as FD
import binascii import binascii
from . import types_pb2 as types from . import types_pb2 as types
__version__ = '0.0.5'
__author__ = 'Paul Dovbush <dpp@dpp.su>'
class ParseError(Exception): pass class ParseError(Exception): pass

@ -1,8 +1,6 @@
from __future__ import print_function from __future__ import print_function
import sys import sys
import math import math
import operator
from PyQt4.QtGui import (QPushButton, QLineEdit, QSizePolicy, QRegExpValidator, QLabel, from PyQt4.QtGui import (QPushButton, QLineEdit, QSizePolicy, QRegExpValidator, QLabel,
QApplication, QWidget, QGridLayout, QVBoxLayout, QHBoxLayout) QApplication, QWidget, QGridLayout, QVBoxLayout, QHBoxLayout)
from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt

@ -77,7 +77,7 @@ class Transport(object):
return None return None
data = self._read() data = self._read()
if data == None: if data is None:
return None return None
return self._parse_message(data) return self._parse_message(data)

@ -1,9 +1,8 @@
'''BridgeTransport implements transport TREZOR Bridge (aka trezord).''' '''BridgeTransport implements transport TREZOR Bridge (aka trezord).'''
import requests
import json import json
import requests
from . import protobuf_json from . import protobuf_json
from . import mapping
from . import messages_pb2 as proto from . import messages_pb2 as proto
from .transport import Transport from .transport import Transport
@ -21,7 +20,7 @@ class BridgeTransport(Transport):
self.session = None self.session = None
self.response = None self.response = None
self.conn = requests.Session(); self.conn = requests.Session()
super(BridgeTransport, self).__init__(device, *args, **kwargs) super(BridgeTransport, self).__init__(device, *args, **kwargs)
@ -81,7 +80,7 @@ class BridgeTransport(Transport):
self.response = r.json() self.response = r.json()
def _read(self): def _read(self):
if self.response == None: if self.response is None:
raise Exception('No response stored') raise Exception('No response stored')
cls = getattr(proto, self.response['type']) cls = getattr(proto, self.response['type'])
inst = cls() inst = cls()

@ -1,12 +1,11 @@
from __future__ import print_function from __future__ import print_function
'''PipeTransport implements fake wire transport over local named pipe.
Use this transport for talking with trezor simulator.'''
import os import os
from select import select from select import select
from .transport import Transport from .transport import Transport
"""PipeTransport implements fake wire transport over local named pipe.
Use this transport for talking with trezor simulator."""
class PipeTransport(Transport): class PipeTransport(Transport):
def __init__(self, device, is_device, *args, **kwargs): def __init__(self, device, is_device, *args, **kwargs):
self.is_device = is_device # Set True if act as device 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 # Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
import serial
from select import select from select import select
import serial
from .transport import Transport from .transport import Transport
class SerialTransport(Transport): class SerialTransport(Transport):

@ -1,17 +1,19 @@
import binascii import binascii
import json
from decimal import Decimal from decimal import Decimal
# from filecache import filecache, DAY # from filecache import filecache, DAY
from . import types_pb2 as proto_types
import requests import requests
from . import types_pb2 as proto_types
def insight_tx(url, rawdata=False): def fetch_json(url):
if not rawdata:
try: try:
r = requests.get(url, headers={'User-agent': 'Mozilla/5.0'}) r = requests.get(url, headers={'User-agent': 'Mozilla/5.0'})
data = r.json() return r.json()
except: except:
raise Exception('URL error: %s' % url) raise Exception('URL error: %s' % url)
def insight_tx(url, rawdata=False):
if not rawdata:
data = fetch_json(url)
else: else:
data = url data = url
@ -42,11 +44,7 @@ def insight_tx(url, rawdata=False):
def smartbit_tx(url, rawdata=False): def smartbit_tx(url, rawdata=False):
if not rawdata: if not rawdata:
try: data = fetch_json(url)
r = requests.get(url, headers = {'User-agent': 'Mozilla/5.0'})
data = r.json()
except:
raise Exception('URL error: %s' % url)
else: else:
data = url data = url

Loading…
Cancel
Save