diff --git a/freedvtnc2/__main__.py b/freedvtnc2/__main__.py index f33983d..4bdcbd8 100644 --- a/freedvtnc2/__main__.py +++ b/freedvtnc2/__main__.py @@ -52,12 +52,13 @@ if __name__ == '__main__': super().__init__() self.log_buffer = "" def emit(self, record): - if record.name == "root" and record.module == "__main__": - msg = HTML(f"{{}}\n").format(record.msg).value - else: - msg = HTML(f"{{}}").format(record.name).value - msg += HTML(f":{{}}").format(record.module).value - msg += HTML(f": {{}}\n").format(record.msg,).value + for message in record.msg.split("\n"): + if record.name == "root" and record.module == "__main__": + msg = HTML(f"{{}}\n").format(message).value + else: + msg = HTML(f"{{}}").format(record.name).value + msg += HTML(f":{{}}").format(record.module).value + msg += HTML(f": {{}}\n").format(message).value if options.no_cli: print(self.format(record)) diff --git a/freedvtnc2/shell.py b/freedvtnc2/shell.py index d6a1e66..f7f02a1 100644 --- a/freedvtnc2/shell.py +++ b/freedvtnc2/shell.py @@ -204,6 +204,10 @@ class FreeDVShellCommands(): "on": None, "off": None } + + def do_exception(self, arg): + "Raises and exemption to test the shell" + raise NotImplementedError("woof\nwoof\n") def do_save_config(self, arg): "Save a config file to ~/.freedvtnc2.conf. Warning this will override your current config" @@ -244,6 +248,7 @@ class FreeDVShell(): ("log.critical.module", 'bold #ff0000'), ("log.critical.msg", 'bold #ff0000'), ("chat.callsign", 'bold #00ff00'), + ("commandoutput.error", 'bold #ff0000'), ] ) def __init__(self, modem_rx: FreeDVRX, modem_tx: FreeDVTX, output_device: audio.OutputDevice, input_device: audio.InputDevice, parser: configargparse.ArgParser, options: argparse.Namespace, logs:str): @@ -283,12 +288,14 @@ class FreeDVShell(): def accept(buff): try: - self.add_text(HTML("> {}\n").format(input_field.text).value) + input_text = input_field.text.replace("\n","") + self.add_text(HTML("> {}\n").format(input_text).value) - command, arg = input_field.text.split(" ", 1) + command, arg = input_text.split(" ", 1) except ValueError: - command = input_field.text + command = input_text arg = "" + additional_class="info" try: command = getattr(self.shell_commands, "do_" + command) try: @@ -302,12 +309,14 @@ class FreeDVShell(): except KeyboardInterrupt: raise KeyboardInterrupt except: + additional_class = "error" output = traceback.format_exc() + "\n" except Exception: output = "Invalid command. Valid commands: " + ", ".join(self.shell_commands.commands) + "\n" - for line in output.split("\n"): - self.add_text(HTML("{}\n").format(line).value) - + if output: + for line in output.split("\n"): + self.add_text(HTML(f"{{}}\n").format(line).value) + input_field = TextArea( height=3, prompt="(freedvtnc2) ", @@ -348,6 +357,8 @@ class FreeDVShell(): ("class:status", f"TX Queue: { len(self.output_device.send_queue) :3.0f} | "), ("class:status", f"Channel: "), (f"class:status.{'red' if self.output_device.inhibit else 'green'}", f"{'busy' if self.output_device.inhibit else 'clear'}"), + ("class:status", f" | TX Mode: "), + (f"class:status", f"{self.modem_tx.modem.modem_name}"), ("class:status", " |\n"), ]