Skip to content

Commit

Permalink
Merge pull request #1661 from dmach/fix-urlquoted-filenames-in-getbin…
Browse files Browse the repository at this point in the history
…aries

Fix urlquoted filenames in getbinaries
  • Loading branch information
dmach authored Nov 12, 2024
2 parents 31f65dd + 531753b commit daf3f02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions osc/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()


Expand Down

0 comments on commit daf3f02

Please sign in to comment.