From 70099cf82d6cf777825172894014fcf981e4ddcd Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Tue, 7 Dec 2021 09:30:10 -0800 Subject: [PATCH] add --support option --- meshtastic/__main__.py | 10 ++++++++++ meshtastic/util.py | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 444c418..2a22038 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -17,6 +17,7 @@ from .tcp_interface import TCPInterface from .ble_interface import BLEInterface from . import test, remote_hardware from . import portnums_pb2, channel_pb2, mesh_pb2, radioconfig_pb2 +from .util import support_info """We only import the tunnel code if we are on a platform that can run it""" have_tunnel = platform.system() == 'Linux' @@ -195,6 +196,7 @@ def onConnected(interface): closeNow = False # Should we drop the connection after we finish? try: global args + print("Connected to radio") def getNode(): @@ -569,6 +571,11 @@ def common(): parser.print_help(sys.stderr) sys.exit(1) else: + if args.support: + print("") + support_info() + sys.exit(0) + if args.ch_index is not None: global channelIndex channelIndex = int(args.ch_index) @@ -788,6 +795,9 @@ def initParser(): parser.add_argument('--version', action='version', version=f"{pkg_resources.require('meshtastic')[0].version}") + parser.add_argument( + "--support", action='store_true', help="Show support info (useful when troubleshooting an issue)") + args = parser.parse_args() diff --git a/meshtastic/util.py b/meshtastic/util.py index 927a28b..c685dfa 100644 --- a/meshtastic/util.py +++ b/meshtastic/util.py @@ -4,10 +4,12 @@ import traceback from queue import Queue import sys import time +import platform import logging import threading import serial import serial.tools.list_ports +import pkg_resources """Some devices such as a seger jlink we never want to accidentally open""" blacklistVids = dict.fromkeys([0x1366]) @@ -111,3 +113,21 @@ class DeferredExecution(): logging.error( f"Unexpected error in deferred execution {sys.exc_info()[0]}") print(traceback.format_exc()) + +def support_info(): + """Print out info that is helping in support of the cli.""" + print('If having issues with meshtastic cli or python library') + print('or wish to make feature requests, visit:') + print('https://github.com/meshtastic/Meshtastic-python/issues') + print('When adding an issue, be sure to include the following info:') + print(' System: {0}'.format(platform.system())) + print(' Platform: {0}'.format(platform.platform())) + print(' Release: {0}'.format(platform.uname().release)) + print(' Machine: {0}'.format(platform.uname().machine)) + print(' meshtastic: v{0}'.format(pkg_resources.require('meshtastic')[0].version)) + print(' Executable: {0}'.format(sys.argv[0])) + print(' Python: {0} {1} {2}'.format(platform.python_version(), + platform.python_implementation(), platform.python_compiler())) + print('') + print('Please add the output from the command: meshtastic --info') + print('')