From 45e4365952c92e32f64e6158cb071f251a1723c7 Mon Sep 17 00:00:00 2001 From: Obijuan Date: Tue, 19 Mar 2024 11:46:53 +0100 Subject: [PATCH] apio upload: Fixed a bug when uploading with fomu --- .vscode/launch.json | 12 ++++++++++++ apio/managers/scons.py | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 76836675..dcfc6268 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -47,6 +47,18 @@ //-- Testing the TinyFPGA board "cwd": "${workspaceFolder}/test-examples/TinyFPGA-BX/01-LED-ON" }, + { + "name": "Upload (Fomu)", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "args": ["upload"], + "console": "internalConsole", + "justMyCode": true, + //-- Change to the folder with the example to test + //-- Testing the TinyFPGA board + "cwd": "${workspaceFolder}/test-examples/fomu/temp-Blinky" + }, { "name": "Upload (Blackice)", "type": "debugpy", diff --git a/apio/managers/scons.py b/apio/managers/scons.py index 2a9129dc..93c6a1bb 100644 --- a/apio/managers/scons.py +++ b/apio/managers/scons.py @@ -991,9 +991,21 @@ def _execute_scons(self, command: str, variables: list, board: str) -> int: @staticmethod def _on_stdout(line): + + # ---- Fomu output processing BEGIN + #pattern_fomu = r"^Download\s*\[=*\]\s\d{1,3}%" + pattern_fomu = r"^Download\s*\[=*" + match = re.search(pattern_fomu, line) + if match: + # -- Delete the previous line + print(CURSOR_UP + ERASE_LINE, end="") + # ---- Fomu output processing END + fgcol = "green" if "is up to date" in line else None + fgcol = "green" if match else fgcol click.secho(line, fg=fgcol) + @staticmethod def _on_stderr(line: str): """Callback function. It is called when the running command @@ -1042,6 +1054,9 @@ def _on_stderr(line: str): # -- Delete the previous line print(CURSOR_UP + ERASE_LINE, end="") # ------- Iceprog output processing END + + + # -- Print the line (In YELLOW) # -- In case of error print it in RED