From e8423007cabf0e2267a21bca2f407de340a26611 Mon Sep 17 00:00:00 2001 From: Charles Martin Date: Tue, 9 Jan 2018 16:55:18 +0100 Subject: [PATCH] now exits script after discover if in discovery mode --- myo_to_osc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/myo_to_osc.py b/myo_to_osc.py index 0263ebb..18cfadb 100644 --- a/myo_to_osc.py +++ b/myo_to_osc.py @@ -6,6 +6,7 @@ import math import logging import argparse +import sys from pythonosc import osc_message_builder from pythonosc import udp_client @@ -87,8 +88,11 @@ def proc_battery(battery_level): m.add_imu_handler(proc_imu) m.add_battery_handler(proc_battery) -if args.discover: # Discovers Myos and prints addresses. - discover_myos(m.bt) +if args.discover: # Discovers Myos and prints addresses, then exits script. + results = discover_myos(m.bt) + if not results: + print("No Myos found.") + sys.exit() m.connect(address=args.address) # connects to specific Myo unless arg.address is none. # Setup Myo mode, buzzes when ready.