mirror of
https://github.com/meshtastic/python.git
synced 2026-04-20 14:58:54 -04:00
Make dotmap (via meshtastic.test) and print_color optional
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user