add error handling and script runs until unexpected error or max reached

This commit is contained in:
Jarrian
2023-09-09 14:19:13 +08:00
parent 8843b4d81e
commit b43fb72dbd
5 changed files with 142 additions and 127 deletions

View File

@@ -11,8 +11,15 @@ class Progress:
self.current = current
progress = current / self.total
bar_length = 40
progress_bar = "[" + "=" * int(bar_length * progress) + \
"-" * (bar_length - int(bar_length * progress)) + "]"
progress_bar = (
"["
+ "=" * int(bar_length * progress)
+ "-" * (bar_length - int(bar_length * progress))
+ "]"
)
sys.stdout.write(
"\rProgress: [{:<40}] {:.2%} {} of {}".format(progress_bar, progress, current, self.total))
"\rProgress: [{:<40}] {:.2%} {} of {}".format(
progress_bar, progress, current, self.total
)
)
sys.stdout.flush()