diff --git a/helloworld.py b/helloworld.py index f0ea1fb..69a802c 100755 --- a/helloworld.py +++ b/helloworld.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function from trezorlib.client import TrezorClient from trezorlib.transport_hid import HidTransport diff --git a/mnemonic_check.py b/mnemonic_check.py index 7ab4324..df0eff4 100755 --- a/mnemonic_check.py +++ b/mnemonic_check.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + __doc__ = ''' Use this script to cross-check that TREZOR generated valid mnemonic sentence for given internal (TREZOR-generated) @@ -42,7 +44,7 @@ def generate_entropy(strength, internal_entropy, external_entropy): raise Exception("External entropy too short") entropy = hashlib.sha256(internal_entropy + external_entropy).digest() - entropy_stripped = entropy[:strength / 8] + entropy_stripped = entropy[:strength // 8] if len(entropy_stripped) * 8 != strength: raise Exception("Entropy length mismatch") @@ -56,7 +58,7 @@ def main(): trzr = binascii.unhexlify(input("Please enter TREZOR-generated entropy (in hex): ").strip()) word_count = int(input("How many words your mnemonic has? ")) - strength = word_count * 32 / 3 + strength = word_count * 32 // 3 entropy = generate_entropy(strength, trzr, comp) diff --git a/signtest.py b/signtest.py old mode 100644 new mode 100755 index 50335b4..d26f823 --- a/signtest.py +++ b/signtest.py @@ -1,4 +1,5 @@ #!/usr/bin/python +from __future__ import print_function import binascii import os import random @@ -78,7 +79,7 @@ class MyTXAPIBitcoin(object): i.script_sig = os.urandom(100) i.sequence = 0xffffffff if (nr % 50 == 0): - print nr + print(nr) myout = random.randint(0, txsize-1) segwit = 1 #random.randint(0,1) for vout in range(txsize): @@ -118,8 +119,8 @@ class MyTXAPIBitcoin(object): prev_hash=txhash, prev_index = myout )) - #print binascii.hexlify(txser) - #print binascii.hexlify(txhash) + #print(binascii.hexlify(txser)) + #print(binascii.hexlify(txhash)) self.txs[binascii.hexlify(txhash)] = t self.outputs = [ @@ -137,7 +138,7 @@ class MyTXAPIBitcoin(object): def get_tx(self, txhash): t = self.txs[txhash] - #print t + #print(t) return t def main(): @@ -149,11 +150,11 @@ def main(): # Check whether we found any if len(devices) == 0: - print 'No TREZOR found' + print('No TREZOR found') return # Use first connected device - print devices[0][0] + print(devices[0][0]) # transport = BridgeTransport(devices[0][0]) transport = HidTransport(devices[0]) @@ -164,14 +165,14 @@ def main(): # client.set_tx_api(TXAPITestnet()) txstore.set_client(client) txstore.set_publickey(client.get_public_node(client.expand_path("44'/0'/0'"))) - print "creating input txs" + print("creating input txs") txstore.create_inputs(numinputs, sizeinputtx) - print "go" + print("go") client.set_tx_api(txstore) # client.set_tx_api(MyTXAPIBitcoin()) # Print out TREZOR's features and settings - print client.features + print(client.features) # Get the first address of first BIP44 account # (should be the same address as shown in mytrezor.com) @@ -215,7 +216,7 @@ def main(): # (signatures, serialized_tx) = client.sign_tx('Testnet', inputs, outputs) (signatures, serialized_tx) = client.sign_tx('Bitcoin', txstore.get_inputs(), txstore.get_outputs()) - print 'Transaction:', binascii.hexlify(serialized_tx) + print('Transaction:', binascii.hexlify(serialized_tx)) client.close() diff --git a/tests/common.py b/tests/common.py index 317e305..581d302 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import config diff --git a/tests/config.py b/tests/config.py index 5475552..7b882e4 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys sys.path = ['../',] + sys.path diff --git a/tests/test_bip32_speed.py b/tests/test_bip32_speed.py index 7a525c1..8c8fa11 100644 --- a/tests/test_bip32_speed.py +++ b/tests/test_bip32_speed.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common import time diff --git a/tests/test_ecies.py b/tests/test_ecies.py index b6564f9..b04b693 100644 --- a/tests/test_ecies.py +++ b/tests/test_ecies.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common import binascii diff --git a/tests/test_msg_getentropy.py b/tests/test_msg_getentropy.py index 4a2c325..f36ec9b 100644 --- a/tests/test_msg_getentropy.py +++ b/tests/test_msg_getentropy.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common import math diff --git a/tests/test_msg_recoverydevice.py b/tests/test_msg_recoverydevice.py index 0ccbdfc..095a344 100644 --- a/tests/test_msg_recoverydevice.py +++ b/tests/test_msg_recoverydevice.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common diff --git a/tests/test_msg_signidentity.py b/tests/test_msg_signidentity.py index cb5ff67..6d093ad 100644 --- a/tests/test_msg_signidentity.py +++ b/tests/test_msg_signidentity.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common import binascii diff --git a/tests/test_multisig.py b/tests/test_multisig.py index 1e60fdc..3bf303c 100644 --- a/tests/test_multisig.py +++ b/tests/test_multisig.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common import binascii diff --git a/tests/test_protect_call.py b/tests/test_protect_call.py index 3810e6b..339e54c 100644 --- a/tests/test_protect_call.py +++ b/tests/test_protect_call.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import time import unittest import common diff --git a/tests/test_zerosig.py b/tests/test_zerosig.py index 98fe5b4..e6dfd3d 100644 --- a/tests/test_zerosig.py +++ b/tests/test_zerosig.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import unittest import common import binascii diff --git a/tools/encfs_aes_getpass.py b/tools/encfs_aes_getpass.py index 265cdc1..87cc70e 100755 --- a/tools/encfs_aes_getpass.py +++ b/tools/encfs_aes_getpass.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function ''' Use TREZOR as a hardware key for opening EncFS filesystem! diff --git a/trezorctl b/trezorctl index ccdabd0..91ab2a1 100755 --- a/trezorctl +++ b/trezorctl @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import os import binascii import argparse diff --git a/trezorlib/client.py b/trezorlib/client.py index a9a316c..6c7a35f 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import os import sys import time diff --git a/trezorlib/debuglink.py b/trezorlib/debuglink.py index a9cbff3..f2c7cd5 100644 --- a/trezorlib/debuglink.py +++ b/trezorlib/debuglink.py @@ -1,3 +1,5 @@ +from __future__ import print_function + from . import messages_pb2 as proto from .transport import NotImplementedException diff --git a/trezorlib/qt/pinmatrix.py b/trezorlib/qt/pinmatrix.py index abad803..4eaabde 100644 --- a/trezorlib/qt/pinmatrix.py +++ b/trezorlib/qt/pinmatrix.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys import math import operator diff --git a/trezorlib/transport_pipe.py b/trezorlib/transport_pipe.py index 9fd47b2..fe3ca57 100644 --- a/trezorlib/transport_pipe.py +++ b/trezorlib/transport_pipe.py @@ -1,3 +1,5 @@ +from __future__ import print_function + '''PipeTransport implements fake wire transport over local named pipe. Use this transport for talking with trezor simulator.''' diff --git a/trezorlib/transport_serial.py b/trezorlib/transport_serial.py index a69c091..6109173 100644 --- a/trezorlib/transport_serial.py +++ b/trezorlib/transport_serial.py @@ -1,3 +1,5 @@ +from __future__ import print_function + '''SerialTransport implements wire transport over serial port.''' # Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9 diff --git a/trezorlib/transport_socket.py b/trezorlib/transport_socket.py index 6a44f56..49652b2 100644 --- a/trezorlib/transport_socket.py +++ b/trezorlib/transport_socket.py @@ -1,3 +1,5 @@ +from __future__ import print_function + '''SocketTransport implements TCP socket interface for Transport.''' import socket