def config(action): if action == "create": if check_config() == False: if create_config() == False: dprint("Error creating configuration directory!", eid=2) else: dprint("Successfully created configuration directory.", eid=0, level=0)
def scan_devices(): device_list = glob.glob("/dev/tty{ACM,USB}*") if not device_list: dprint(("No devices found. Add -d [PATH] " "to manually include the port " "path e.g. /dev/ttyACM0"), eid=2) exit() # Select first device found return device_list[0]
def cli(ctx, verbose): global __debug_level__ __debug_level__ = verbose set_level(__debug_level__) if ctx.invoked_subcommand != "config": if check_config() == False: dprint( "Configuration not found! Run `mirp_cli config create` to generate.", eid=2) if ctx.invoked_subcommand == None: dprint( "No commands specified! Run with --help to list all the commands avaliable.", eid=1, level=0)
def create_config(nodes={}, config={}): dprint("Running create_config()") try: os.makedirs(__home__ + __default_dir__) except OSError as exception: if exception.errno != errno.EEXIST: return False dprint("Checking whether nodes.json exists...") if not os.path.isfile(__home__ + __default_dir__ + "/nodes.json"): with open(__home__ + __default_dir__ + "/nodes.json", "w") as f: json.dump(nodes, f) dprint("nodes.json created!", eid=0) dprint("Checking whether config.json exists...") if not os.path.isfile(__home__ + __default_dir__ + "/config.json"): with open(__home__ + __default_dir__ + "/config.json", "w") as f: json.dump(config, f) dprint("config.json created!", eid=0) return True
def monitor(device): if device == "auto": # Detect device device = scan_devices() dprint("Selected device under " + device + ".", level=1, eid=-1)
def clist(): dprint("hello!", eid=3)
def test_styles(): dprint("normal") dprint("success", eid=0) dprint("warning", eid=1) dprint("failure", eid=2) dprint("additional information\nthis can span many\nlines...", eid=3)