Make dotmap (via meshtastic.test) and print_color optional

This commit is contained in:
Ian McEwen
2024-12-12 20:59:22 -07:00
parent 89b41c1a19
commit 31f322f1c2
5 changed files with 24 additions and 13 deletions

View File

@@ -80,7 +80,6 @@ from typing import *
import google.protobuf.json_format
import serial # type: ignore[import-untyped]
from dotmap import DotMap # type: ignore[import-untyped]
from google.protobuf.json_format import MessageToJson
from pubsub import pub # type: ignore[import-untyped]
from tabulate import tabulate

View File

@@ -18,7 +18,12 @@ import yaml
from google.protobuf.json_format import MessageToDict
from pubsub import pub # type: ignore[import-untyped]
import meshtastic.test
try:
import meshtastic.test
have_test = True
except ImportError as e:
have_test = False
import meshtastic.util
from meshtastic import BROADCAST_ADDR, mt_config, remote_hardware
from meshtastic.ble_interface import BLEInterface
@@ -1143,11 +1148,14 @@ def common():
parser.print_help(sys.stderr)
meshtastic.util.our_exit("", 1)
elif args.test:
result = meshtastic.test.testAll()
if not result:
meshtastic.util.our_exit("Warning: Test was not successful.")
if not have_test:
meshtastic.util.our_exit("Test module could not be important. Ensure you have the 'dotmap' module installed.")
else:
meshtastic.util.our_exit("Test was a success.", 0)
result = meshtastic.test.testAll()
if not result:
meshtastic.util.our_exit("Warning: Test was not successful.")
else:
meshtastic.util.our_exit("Test was a success.", 0)
else:
if args.seriallog == "stdout":
logfile = sys.stdout

View File

@@ -15,7 +15,11 @@ from decimal import Decimal
from typing import Any, Callable, Dict, List, Optional, Union
import google.protobuf.json_format
import print_color # type: ignore[import-untyped]
try:
import print_color # type: ignore[import-untyped]
except ImportError as e:
print_color = None
from pubsub import pub # type: ignore[import-untyped]
from tabulate import tabulate
@@ -153,7 +157,7 @@ class MeshInterface: # pylint: disable=R0902
@staticmethod
def _printLogLine(line, interface):
"""Print a line of log output."""
if interface.debugOut == sys.stdout:
if print_color is not None and interface.debugOut == sys.stdout:
# this isn't quite correct (could cause false positives), but currently our formatting differs between different log representations
if "DEBUG" in line:
print_color.print(line, color="cyan", end=None)

6
poetry.lock generated
View File

@@ -944,7 +944,7 @@ profile = ["gprof2dot (>=2022.7.29)"]
name = "dotmap"
version = "1.3.30"
description = "ordered, dynamically-expandable dot-access dictionary"
optional = false
optional = true
python-versions = "*"
files = [
{file = "dotmap-1.3.30-py3-none-any.whl", hash = "sha256:bd9fa15286ea2ad899a4d1dc2445ed85a1ae884a42effb87c89a6ecce71243c6"},
@@ -2705,7 +2705,7 @@ pyserial = "*"
name = "print-color"
version = "0.4.6"
description = "A simple package to print in color to the terminal"
optional = false
optional = true
python-versions = ">=3.7,<4.0"
files = [
{file = "print_color-0.4.6-py3-none-any.whl", hash = "sha256:494bd1cdb84daf481f0e63bd22b3c32f7d52827d8f5d9138a96bb01ca8ba9299"},
@@ -4337,4 +4337,4 @@ tunnel = ["pytap2"]
[metadata]
lock-version = "2.0"
python-versions = "^3.9,<3.14"
content-hash = "cc2529666461aa69024abd86d14b2ac220a965a82dded2309b9e0980f5e1b328"
content-hash = "21b6a8041c1bbd7b970a7af37621690715db771488950c72087e60d922a2ff95"

View File

@@ -10,7 +10,6 @@ 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"
dotmap = "^1.3.30"
pyqrcode = "^1.2.1"
tabulate = "^0.9.0"
requests = "^2.31.0"
@@ -18,7 +17,8 @@ pyyaml = "^6.0.1"
pypubsub = "^4.0.3"
bleak = "^0.22.3"
packaging = "^24.0"
print-color = "^0.4.6"
dotmap = { version = "^1.3.30", optional = true }
print-color = { version = "^0.4.6", optional = true }
dash = { version = "^2.17.1", optional = true }
pytap2 = { version = "^2.3.0", optional = true }
dash-bootstrap-components = { version = "^1.6.0", optional = true }