From 26435130d7677aa35fb66e144233a74b9fa4ba49 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Wed, 12 Oct 2016 21:13:03 +0300 Subject: [PATCH] factory: emit warning (instead of exception) when an import fails --- trezor_agent/factory.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/trezor_agent/factory.py b/trezor_agent/factory.py index e33ce00..fc9c66f 100644 --- a/trezor_agent/factory.py +++ b/trezor_agent/factory.py @@ -59,8 +59,9 @@ def _load_trezor(): identity_type=IdentityType, required_version='>=1.4.0', call_exception=CallException) - except ImportError: - log.exception('Missing module: install via "pip install trezor"') + except ImportError as e: + log.warning('%s: install via "pip install trezor" ' + 'if you need to support this device', e) def _load_keepkey(): @@ -76,8 +77,9 @@ def _load_keepkey(): identity_type=IdentityType, required_version='>=1.0.4', call_exception=CallException) - except ImportError: - log.exception('Missing module: install via "pip install keepkey"') + except ImportError as e: + log.warning('%s: install via "pip install keepkey" ' + 'if you need to support this device', e) def _load_ledger(): @@ -213,8 +215,10 @@ def _load_ledger(): self.args = [code, message] try: from ledgerblue.comm import getDongle - except ImportError: - log.exception('Missing module: install via "pip install ledgerblue"') + except ImportError as e: + log.warning('%s: install via "pip install ledgerblue" ' + 'if you need to support this device', e) + return # pylint: disable=bare-except try: from trezorlib.types_pb2 import IdentityType # pylint: disable=import-error