CLI: filter out useless progress refresh on stdout.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 05 Jan 2025 23:05:08 +0100 (2 months ago)
changeset 4086 0f5a69ab57a1
parent 4077 03ed01134858
child 4087 70a8d4893c06
CLI: filter out useless progress refresh on stdout.
CLIController.py
--- a/CLIController.py	Tue Dec 17 21:18:40 2024 +0100
+++ b/CLIController.py	Sun Jan 05 23:05:08 2025 +0100
@@ -19,12 +19,13 @@
 class Log:
 
     def __init__(self):
-        self.crlfpending = False
+        self.last_progress = None
 
     def write(self, s):
         if s:
-            if self.crlfpending:
-                sys.stdout.write("\n")
+            if self.last_progress:
+                sys.stdout.write(f"{self.last_progress}\n")
+                self.last_progress = None
             sys.stdout.write(s)
             sys.stdout.flush()
             self.crlfpending = 0
@@ -44,10 +45,7 @@
         return False
 
     def progress(self, s):
-        if s:
-            sys.stdout.write(s+"\r")
-            self.crlfpending = True
-
+        self.last_progress = s
 
 def with_project_loaded(func):
     @wraps(func)