import os from . import run_application def check_icon(icon_name): own_path = os.path.abspath(__file__) own_dir = os.path.dirname(own_path) icon_path = os.path.join(own_dir, 'appicons', icon_name) if os.path.isfile(icon_path): return icon_path return None def run_magnetic_trap(): arduino_commands = {'open': 'o', 'close': 'c'} icon = check_icon('Household-Mouse-Trap.ico') run_application(arduino_commands, "It's a trap!", icon=icon)