Skip to content

Commit

Permalink
Prevent failing when progress goes over 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Dec 24, 2023
1 parent d3d703f commit ff63520
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions openandroidinstaller/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def display_progress_bar(self, line: str):
percentage_done = int(result.group(1))
if percentage_done == 0:
percentage_done = 1
elif percentage_done == 100:
elif percentage_done >= 100:
percentage_done = 99

# update the progress bar
Expand All @@ -153,9 +153,10 @@ def set_progress_bar(self, percentage_done: int):
Args:
percentage_done (int): Percentage of the progress bar to be filled.
"""
assert (
percentage_done >= 0 and percentage_done <= 100
), "Percentage must be between 0 and 100"
assert percentage_done >= 0, "Percentage must be non-negative."
# clip the percentage to 100
if percentage_done > 100:
percentage_done = 100
if self.progress_bar:
self.progress_bar.value = percentage_done / 100
self.percentage_text.value = f"{percentage_done}%"
Expand Down

0 comments on commit ff63520

Please sign in to comment.