From 5029c043bbd4a1e8dabfce6195cbc47d28c8188c Mon Sep 17 00:00:00 2001 From: Karel Blavka Date: Sun, 31 Dec 2017 21:03:54 +0100 Subject: [PATCH] Remove dafault --device --- bcg/gateway.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bcg/gateway.py b/bcg/gateway.py index c36ddb3..01f07c8 100755 --- a/bcg/gateway.py +++ b/bcg/gateway.py @@ -452,11 +452,6 @@ def command_devices(verbose=False, include_links=False): def main(): - devices = sorted(serial.tools.list_ports.comports()) - - if devices: - config['device'] = devices[0][0] - argp = argparse.ArgumentParser(description='BigClown gateway between USB serial port and MQTT broker') subparsers = {} @@ -467,9 +462,7 @@ def main(): subparsers['devices'].add_argument('-s', '--include-links', action='store_true', help='include entries that are symlinks to real devices') argp.add_argument('-c', '--config', help='path to configuration file (YAML format)') - argp.add_argument('-d', '--device', - help='path to gateway serial port' + ' (default is ' + config['device'] + ')' if config['device'] else '', - default=config['device']) + argp.add_argument('-d', '--device', help='device', required='-c' not in sys.argv and '--config' not in sys.argv) argp.add_argument('-H', '--mqtt-host', help='MQTT host to connect to (default is localhost)') argp.add_argument('-P', '--mqtt-port', help='MQTT port to connect to (default is 1883)') argp.add_argument('--no-wait', help='no wait on connect or reconnect serial port', action='store_true') @@ -519,7 +512,8 @@ def main(): except Exception as e: logging.error('Failed opening configuration file') - raise e + if os.getenv('DEBUG', False): + raise e sys.exit(1) config['device'] = args.device if args.device else config['device'] @@ -546,6 +540,7 @@ def main(): logging.error(e) if os.getenv('DEBUG', False): raise e + sys.exit(1) if __name__ == '__main__':