|
13 | 13 | import time |
14 | 14 | from typing import List, Optional |
15 | 15 |
|
16 | | -import pyqrcode # type: ignore[import-untyped] |
| 16 | +try: |
| 17 | + import pyqrcode # type: ignore[import-untyped] |
| 18 | +except ImportError as e: |
| 19 | + pyqrcode = None |
| 20 | + |
17 | 21 | import yaml |
18 | 22 | from google.protobuf.json_format import MessageToDict |
19 | 23 | from pubsub import pub # type: ignore[import-untyped] |
20 | 24 |
|
21 | | -import meshtastic.test |
| 25 | +try: |
| 26 | + import meshtastic.test |
| 27 | + have_test = True |
| 28 | +except ImportError as e: |
| 29 | + have_test = False |
| 30 | + |
22 | 31 | import meshtastic.util |
23 | 32 | from meshtastic import BROADCAST_ADDR, mt_config, remote_hardware |
24 | 33 | from meshtastic.ble_interface import BLEInterface |
@@ -891,8 +900,11 @@ def setSimpleConfig(modem_preset): |
891 | 900 | else: |
892 | 901 | urldesc = "Primary channel URL" |
893 | 902 | print(f"{urldesc}: {url}") |
894 | | - qr = pyqrcode.create(url) |
895 | | - print(qr.terminal()) |
| 903 | + if pyqrcode is not None: |
| 904 | + qr = pyqrcode.create(url) |
| 905 | + print(qr.terminal()) |
| 906 | + else: |
| 907 | + print("Install pyqrcode to view a QR code printed to terminal.") |
896 | 908 |
|
897 | 909 | log_set: Optional = None # type: ignore[annotation-unchecked] |
898 | 910 | # we need to keep a reference to the logset so it doesn't get GCed early |
@@ -1143,11 +1155,14 @@ def common(): |
1143 | 1155 | parser.print_help(sys.stderr) |
1144 | 1156 | meshtastic.util.our_exit("", 1) |
1145 | 1157 | elif args.test: |
1146 | | - result = meshtastic.test.testAll() |
1147 | | - if not result: |
1148 | | - meshtastic.util.our_exit("Warning: Test was not successful.") |
| 1158 | + if not have_test: |
| 1159 | + meshtastic.util.our_exit("Test module could not be important. Ensure you have the 'dotmap' module installed.") |
1149 | 1160 | else: |
1150 | | - meshtastic.util.our_exit("Test was a success.", 0) |
| 1161 | + result = meshtastic.test.testAll() |
| 1162 | + if not result: |
| 1163 | + meshtastic.util.our_exit("Warning: Test was not successful.") |
| 1164 | + else: |
| 1165 | + meshtastic.util.our_exit("Test was a success.", 0) |
1151 | 1166 | else: |
1152 | 1167 | if args.seriallog == "stdout": |
1153 | 1168 | logfile = sys.stdout |
|
0 commit comments