Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions micropython/lora/lora/lora/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,36 @@

ok = False # Flag if at least one modem driver package is installed


def _can_ignore_error(e):
"""Check if ImportError can be ignored due to missing module."""
return all(x in str(e) for x in ["no module named", "lora"])


# Various lora "sub-packages"

try:
from .sx126x import * # noqa: F401

ok = True
except ImportError as e:
if "no module named 'lora." not in str(e):
if not _can_ignore_error(e):
raise

try:
from .sx127x import * # noqa: F401

ok = True
except ImportError as e:
if "no module named 'lora." not in str(e):
if not _can_ignore_error(e):
raise

try:
from .stm32wl5 import * # noqa: F401

ok = True
except ImportError as e:
if "no module named 'lora." not in str(e):
if not _can_ignore_error(e):
raise


Expand Down
Loading