Skip to content

Commit

Permalink
Merge #474: Warn when device dependency is missing
Browse files Browse the repository at this point in the history
6bd10bc Warn when device dependency is missing (Andrew Chow)

Pull request description:

  When there's a missing dependency or other error when importing a device's implementation, it can be annoying to debug it. This PR adds a warning log when this occurs so that it is easier to see what went wrong with the device implementation.

  Fixes #141

ACKs for top commit:
  instagibbs:
    utACK 6bd10bc

Tree-SHA512: 8462e03f11f562097dc120262ab58ac828ff2eaf7953a5ac45949044acf29ec8431a66e954f4b99be17bd548599bdb9d49d03dec866116c124ff2248ea076bdf
  • Loading branch information
instagibbs committed Mar 1, 2021
2 parents 1f08345 + 6bd10bc commit 7b34fc7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hwilib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""

import importlib
import logging
import platform

from ._base58 import xpub_to_pub_hex
Expand Down Expand Up @@ -109,8 +110,11 @@ def enumerate(password: str = "") -> List[Dict[str, Any]]:
try:
imported_dev = importlib.import_module('.devices.' + module, __package__)
result.extend(imported_dev.enumerate(password)) # type: ignore
except ImportError:
pass # Ignore ImportErrors, the user may not have all device dependencies installed
except ImportError as e:
# Warn for ImportErrors, but largely ignore them to allow users not install
# all device dependencies if only one or some devices are wanted.
logging.warn(f"{e}, required for {module}. Ignore if you do not want this device.")
pass
return result

# Fingerprint or device type required
Expand Down

0 comments on commit 7b34fc7

Please sign in to comment.