From 5de754c5ab7e650fd3344c22a68be747c6a71886 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 5 Jan 2022 23:03:06 +0000 Subject: [PATCH] improve the permission error on linux --- meshtastic/__main__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 8a95ad5..32bc746 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -5,6 +5,7 @@ import argparse import platform import logging +import os import sys import time import yaml @@ -635,12 +636,19 @@ def common(): elif args.host: client = meshtastic.tcp_interface.TCPInterface(args.host, debugOut=logfile, noProto=args.noproto) else: - client = meshtastic.serial_interface.SerialInterface(args.port, debugOut=logfile, noProto=args.noproto) + try: + client = meshtastic.serial_interface.SerialInterface(args.port, debugOut=logfile, noProto=args.noproto) + except PermissionError as ex: + username = os.getlogin() + message = "Permission Error:\n" + message += " Need to add yourself to the 'dialout' group by running:\n" + message += f" sudo usermod -a -G dialout {username}\n" + message += " After running that command, log out and re-login for it to take effect.\n" + message += f"Error was:{ex}" + meshtastic.util.our_exit(message) # We assume client is fully connected now onConnected(client) - #if logfile: - #logfile.close() have_tunnel = platform.system() == 'Linux' if args.noproto or args.reply or (have_tunnel and args.tunnel): # loop until someone presses ctrlc