Skip to content

Commit 31f322f

Browse files
committed
Make dotmap (via meshtastic.test) and print_color optional
1 parent 89b41c1 commit 31f322f

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

meshtastic/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
8080

8181
import google.protobuf.json_format
8282
import serial # type: ignore[import-untyped]
83-
from dotmap import DotMap # type: ignore[import-untyped]
8483
from google.protobuf.json_format import MessageToJson
8584
from pubsub import pub # type: ignore[import-untyped]
8685
from tabulate import tabulate

meshtastic/__main__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
from google.protobuf.json_format import MessageToDict
1919
from pubsub import pub # type: ignore[import-untyped]
2020

21-
import meshtastic.test
21+
try:
22+
import meshtastic.test
23+
have_test = True
24+
except ImportError as e:
25+
have_test = False
26+
2227
import meshtastic.util
2328
from meshtastic import BROADCAST_ADDR, mt_config, remote_hardware
2429
from meshtastic.ble_interface import BLEInterface
@@ -1143,11 +1148,14 @@ def common():
11431148
parser.print_help(sys.stderr)
11441149
meshtastic.util.our_exit("", 1)
11451150
elif args.test:
1146-
result = meshtastic.test.testAll()
1147-
if not result:
1148-
meshtastic.util.our_exit("Warning: Test was not successful.")
1151+
if not have_test:
1152+
meshtastic.util.our_exit("Test module could not be important. Ensure you have the 'dotmap' module installed.")
11491153
else:
1150-
meshtastic.util.our_exit("Test was a success.", 0)
1154+
result = meshtastic.test.testAll()
1155+
if not result:
1156+
meshtastic.util.our_exit("Warning: Test was not successful.")
1157+
else:
1158+
meshtastic.util.our_exit("Test was a success.", 0)
11511159
else:
11521160
if args.seriallog == "stdout":
11531161
logfile = sys.stdout

meshtastic/mesh_interface.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
from typing import Any, Callable, Dict, List, Optional, Union
1616

1717
import google.protobuf.json_format
18-
import print_color # type: ignore[import-untyped]
18+
try:
19+
import print_color # type: ignore[import-untyped]
20+
except ImportError as e:
21+
print_color = None
22+
1923
from pubsub import pub # type: ignore[import-untyped]
2024
from tabulate import tabulate
2125

@@ -153,7 +157,7 @@ def __exit__(self, exc_type, exc_value, trace):
153157
@staticmethod
154158
def _printLogLine(line, interface):
155159
"""Print a line of log output."""
156-
if interface.debugOut == sys.stdout:
160+
if print_color is not None and interface.debugOut == sys.stdout:
157161
# this isn't quite correct (could cause false positives), but currently our formatting differs between different log representations
158162
if "DEBUG" in line:
159163
print_color.print(line, color="cyan", end=None)

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ readme = "README.md"
1010
python = "^3.9,<3.14" # 3.9 is needed for pandas, bleak requires <3.14
1111
pyserial = "^3.5"
1212
protobuf = ">=4.21.12"
13-
dotmap = "^1.3.30"
1413
pyqrcode = "^1.2.1"
1514
tabulate = "^0.9.0"
1615
requests = "^2.31.0"
1716
pyyaml = "^6.0.1"
1817
pypubsub = "^4.0.3"
1918
bleak = "^0.22.3"
2019
packaging = "^24.0"
21-
print-color = "^0.4.6"
20+
dotmap = { version = "^1.3.30", optional = true }
21+
print-color = { version = "^0.4.6", optional = true }
2222
dash = { version = "^2.17.1", optional = true }
2323
pytap2 = { version = "^2.3.0", optional = true }
2424
dash-bootstrap-components = { version = "^1.6.0", optional = true }

0 commit comments

Comments
 (0)