style: bare excepts, left-over bad imports

pull/25/head
matejcik 6 years ago
parent 8226742ea3
commit 29f928e4f2

@ -1,6 +1,4 @@
#!/usr/bin/env python3
from __future__ import print_function
'''
Use TREZOR as a hardware key for opening EncFS filesystem!
@ -62,7 +60,7 @@ def choose_device(devices):
try:
device_id = int(input())
return devices[device_id]
except:
except Exception:
raise ValueError("Invalid choice, exiting...")

@ -2,7 +2,6 @@
from trezorlib.debuglink import DebugLink
from trezorlib.client import TrezorClient
from trezorlib.transport import enumerate_devices
import binascii
import sys
sectoraddrs = [0x8000000, 0x8004000, 0x8008000, 0x800c000,

@ -4,7 +4,6 @@
# that has DEBUG_RNG == 1 as that will disable the user button
# push confirmation
from __future__ import print_function
import io
import sys
from trezorlib.client import TrezorClient

@ -96,10 +96,10 @@ def cli(ctx, path, verbose, is_json):
def get_device():
try:
device = get_transport(path, prefix_search=False)
except:
except Exception:
try:
device = get_transport(path, prefix_search=True)
except:
except Exception:
click.echo("Failed to find a TREZOR device.")
if path is not None:
click.echo("Using path: {}".format(path))

@ -21,7 +21,7 @@ from typing import Iterable, Tuple
from . import messages
from .tools import expect
from trezorlib import _ed25519
from . import _ed25519
# XXX, these could be NewType's, but that would infect users of the cosi module with these types as well.
# Unsure if we want that.
@ -90,7 +90,7 @@ def sign_with_privkey(digest: bytes, privkey: Ed25519PrivateKey,
return Ed25519Signature(_ed25519.encodeint(S))
### Client functions ###
# ====== Client functions ====== #
@expect(messages.CosiCommitment)

@ -6,7 +6,7 @@ def int_to_big_endian(value):
return value.to_bytes((value.bit_length() + 7) // 8, 'big')
### Client functions ###
# ====== Client functions ====== #
@expect(proto.EthereumAddress, field="address")

@ -130,12 +130,12 @@ def validate_firmware(filename):
try:
cosi.verify(header.signature, digest, global_pk)
print("Signature OK")
except:
except Exception:
print("Signature FAILED")
raise
### Client functions ###
# ====== Client functions ====== #
@tools.session

@ -167,7 +167,7 @@ def create_sign_tx(transaction):
return msg
### Client functions ###
# ====== Client functions ====== #
@expect(proto.NEMAddress, field="address")

@ -14,8 +14,6 @@
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
from __future__ import absolute_import
from io import BytesIO
import logging
import struct
@ -79,7 +77,7 @@ class ProtocolV1:
try:
headerlen = struct.calcsize('>HL')
msg_type, datalen = struct.unpack('>HL', chunk[3:3 + headerlen])
except:
except Exception:
raise RuntimeError('Cannot parse header')
data = chunk[3 + headerlen:]

@ -14,8 +14,6 @@
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
from __future__ import absolute_import
from io import BytesIO
import logging
import struct
@ -110,7 +108,7 @@ class ProtocolV2:
try:
headerlen = struct.calcsize('>BLLL')
magic, session, msg_type, datalen = struct.unpack('>BLLL', chunk[:headerlen])
except:
except Exception:
raise RuntimeError('Cannot parse header')
if magic != 0x01:
raise RuntimeError('Unexpected magic character')
@ -122,7 +120,7 @@ class ProtocolV2:
try:
headerlen = struct.calcsize('>BLL')
magic, session, sequence = struct.unpack('>BLL', chunk[:headerlen])
except:
except Exception:
raise RuntimeError('Cannot parse header')
if magic != 0x02:
raise RuntimeError('Unexpected magic characters')
@ -134,7 +132,7 @@ class ProtocolV2:
try:
headerlen = struct.calcsize('>BL')
magic, session = struct.unpack('>BL', chunk[:headerlen])
except:
except Exception:
raise RuntimeError('Cannot parse header')
if magic != 0x03:
raise RuntimeError('Unexpected magic character')

@ -14,7 +14,6 @@
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
from __future__ import print_function
import sys
import math
@ -22,7 +21,7 @@ try:
from PyQt4.QtGui import (QPushButton, QLineEdit, QSizePolicy, QRegExpValidator, QLabel,
QApplication, QWidget, QGridLayout, QVBoxLayout, QHBoxLayout)
from PyQt4.QtCore import QObject, SIGNAL, QRegExp, Qt, QT_VERSION_STR
except:
except ImportError:
from PyQt5.QtWidgets import (QPushButton, QLineEdit, QSizePolicy, QLabel,
QApplication, QWidget, QGridLayout, QVBoxLayout, QHBoxLayout)
from PyQt5.QtGui import QRegExpValidator

@ -338,7 +338,7 @@ def _crc16_checksum(bytes):
return crc & 0xffff
### Client functions ###
# ====== Client functions ====== #
@expect(messages.StellarPublicKey, field="public_key")

@ -59,7 +59,7 @@ class BridgeTransport(Transport):
if r.status_code != 200:
raise TransportException('trezord: Could not enumerate devices' + get_error(r))
return [BridgeTransport(dev) for dev in r.json()]
except:
except Exception:
return []
def open(self):

@ -95,7 +95,7 @@ class UdpTransport(Transport):
try:
self.socket.sendall(b'PINGPING')
resp = self.socket.recv(8)
except:
except Exception:
pass
return resp == b'PONGPONG'

@ -52,7 +52,7 @@ class TxApi(object):
try: # looking into cache first
j = json.load(open(cache_file), parse_float=str)
return j
except:
except Exception:
pass
if not self.url:
@ -62,12 +62,12 @@ class TxApi(object):
url = self.get_url(resource, resourceid)
r = requests.get(url, headers={'User-agent': 'Mozilla/5.0'})
j = r.json(parse_float=str)
except:
except Exception:
raise RuntimeError('URL error: %s' % url)
if cache_dir and cache_file:
try: # saving into cache
json.dump(j, open(cache_file, 'w'))
except:
except Exception:
pass
return j

Loading…
Cancel
Save