From 0638bd08cf24e725732d995c36f76cd68722fda4 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 11 Nov 2024 16:43:46 +0100 Subject: [PATCH 1/2] Avoid printing urlquoted file names in 'getbinaries' command --- osc/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osc/core.py b/osc/core.py index 265f88360..f45f3e052 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2680,7 +2680,7 @@ def download(url: str, filename, progress_obj=None, mtime=None): os.fchmod(fd, 0o644) try: o = os.fdopen(fd, 'wb') - for buf in streamfile(url, http_GET, BUFSIZE, progress_obj=progress_obj): + for buf in streamfile(url, http_GET, BUFSIZE, progress_obj=progress_obj, text=filename): if isinstance(buf, str): o.write(bytes(buf, "utf-8")) else: From 531753b2e5c3304ed5bffb3adbca9014b3695756 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 11 Nov 2024 16:52:46 +0100 Subject: [PATCH 2/2] Hide progressbar.Bar widget after ProgressBar has completed --- osc/meter.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osc/meter.py b/osc/meter.py index f4bfd68b5..4e6a7c230 100644 --- a/osc/meter.py +++ b/osc/meter.py @@ -37,14 +37,14 @@ def __init__(self): def start(self, basename: str, size: Optional[int] = None): if size is None: - widgets = [f"{basename}: ", pb.AnimatedMarker(), ' ', pb.Timer()] + widgets = [f"{basename} ", pb.AnimatedMarker(), ' ', pb.Timer()] self.bar = pb.ProgressBar(widgets=widgets, maxval=pb.UnknownLength) else: - widgets = [f"{basename}: ", pb.Bar(), ' ', pb.ETA()] + widgets = [f"{basename} ", pb.Bar(), ' ', pb.ETA()] if size: # if size is 0, using pb.Percentage will result in # a ZeroDivisionException - widgets.insert(1, pb.Percentage()) + widgets[3:3] = [pb.Percentage(), " "] self.bar = pb.ProgressBar(widgets=widgets, maxval=size) # When a signal handler is set, it resets SA_RESTART flag # - see signal.siginterrupt() python docs. @@ -57,6 +57,15 @@ def update(self, amount_read: int): self.bar.update(amount_read) def end(self): + # replace marker (ticks) and left+right borders of the bar with spaces + # to hide it from output after completion + for i in self.bar.widgets: + if not isinstance(i, pb.Bar): + continue + i.marker = " " + i.left = " " + i.right = " " + self.bar.finish()