Skip to content

Commit

Permalink
Minor improvements to progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Dec 26, 2023
1 parent d0b6c6f commit bb1cd20
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions openandroidinstaller/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def write_line(self, line: str):
Ignores empty lines.
"""
if (type(line) == str) and line.strip():
if isinstance(line, str) and line.strip():
self._box.content.controls[0].value += f"\n>{line.strip()}"
self._box.content.controls[0].value = self._box.content.controls[
0
Expand Down Expand Up @@ -115,7 +115,7 @@ def display_progress_bar(self, line: str):
percentage_done = None
result = None
# create the progress bar
if self.progress_bar == None:
if not self.progress_bar:
self.progress_bar = ProgressBar(
value=1 / 100,
width=500,
Expand All @@ -129,7 +129,7 @@ def display_progress_bar(self, line: str):
Row([self.percentage_text, self.progress_bar])
)
# get the progress numbers from the output lines
if (type(line) == str) and line.strip():
if isinstance(line, str) and line.strip():
result = re.search(
r"\(\~(\d{1,3})\%\)|(Total xfer:|adb: failed to read command: Success)",
line.strip(),
Expand All @@ -139,10 +139,7 @@ def display_progress_bar(self, line: str):
percentage_done = 99
elif result.group(1):
percentage_done = int(result.group(1))
if percentage_done == 0:
percentage_done = 1
elif percentage_done == 100:
percentage_done = 99
percentage_done = max(1, min(99, percentage_done))

# update the progress bar
self.set_progress_bar(percentage_done)
Expand Down

0 comments on commit bb1cd20

Please sign in to comment.