diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 00c1272..6229e7d 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -13,7 +13,11 @@ import sys import time from typing import List, Optional -import pyqrcode # type: ignore[import-untyped] +try: + import pyqrcode # type: ignore[import-untyped] +except ImportError as e: + pyqrcode = None + import yaml from google.protobuf.json_format import MessageToDict from pubsub import pub # type: ignore[import-untyped] @@ -896,8 +900,11 @@ def onConnected(interface): else: urldesc = "Primary channel URL" print(f"{urldesc}: {url}") - qr = pyqrcode.create(url) - print(qr.terminal()) + if pyqrcode is not None: + qr = pyqrcode.create(url) + print(qr.terminal()) + else: + print("Install pyqrcode to view a QR code printed to terminal.") log_set: Optional = None # type: ignore[annotation-unchecked] # we need to keep a reference to the logset so it doesn't get GCed early diff --git a/poetry.lock b/poetry.lock index 455ee20..63d0c4e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3094,7 +3094,7 @@ files = [ name = "pyqrcode" version = "1.2.1" description = "A QR code generator written purely in Python with SVG, EPS, PNG and terminal output." -optional = false +optional = true python-versions = "*" files = [ {file = "PyQRCode-1.2.1.tar.gz", hash = "sha256:fdbf7634733e56b72e27f9bce46e4550b75a3a2c420414035cae9d9d26b234d5"}, @@ -4337,4 +4337,4 @@ tunnel = ["pytap2"] [metadata] lock-version = "2.0" python-versions = "^3.9,<3.14" -content-hash = "21b6a8041c1bbd7b970a7af37621690715db771488950c72087e60d922a2ff95" +content-hash = "d3eefb76e586ad6625c1fce7b73244ba1d663aa5b4916c47bd1daa5f2bdcc913" diff --git a/pyproject.toml b/pyproject.toml index 9950923..d0b0bf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ readme = "README.md" python = "^3.9,<3.14" # 3.9 is needed for pandas, bleak requires <3.14 pyserial = "^3.5" protobuf = ">=4.21.12" -pyqrcode = "^1.2.1" tabulate = "^0.9.0" requests = "^2.31.0" pyyaml = "^6.0.1" pypubsub = "^4.0.3" bleak = "^0.22.3" packaging = "^24.0" +pyqrcode = { version = "^1.2.1", optional = true } dotmap = { version = "^1.3.30", optional = true } print-color = { version = "^0.4.6", optional = true } dash = { version = "^2.17.1", optional = true }