Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck progress bar #89

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pleskdistup/common/src/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def display(self) -> None:
start_time = int(time.time())
passed_time = 0

while passed_time < self.total_time and not self.flow.is_finished():
while passed_time <= self.total_time and not self.flow.is_finished():
percent = int((passed_time) / self.total_time * 100)

description = self.get_action_description()
Expand Down Expand Up @@ -544,6 +544,6 @@ def display(self) -> None:
time.sleep(1)
passed_time = int(time.time()) - start_time

if passed_time > self.total_time:
if passed_time >= self.total_time:
self.write("\r\033[91m[" + "X" * 25 + self.get_action_description() + "X" * 25 + "] exceed\033[0m")
self.write(self.time_exceeded_message)
25 changes: 22 additions & 3 deletions pleskdistup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ def show_status(status_file_path: PathType) -> None:
print("Conversion process is not running.")
return

print("Conversion process in progress:")
status = files.get_last_lines(status_file_path, 1)
print(status[0])
# This means progress bar exceeded and we should write last 5 lines of the status file
if status[0].startswith("****"):
status = files.get_last_lines(status_file_path, 5)
else:
print("Conversion process in progress:")

for line in status:
print(line, end='')


def monitor_status(status_file_path: PathType) -> None:
Expand All @@ -83,13 +89,26 @@ def monitor_status(status_file_path: PathType) -> None:
return

with open(status_file_path, "r") as status:
status.readlines()
old_lines = status.readlines()
if old_lines[-1].startswith("****"):
for lines in old_lines[-5:]:
print(lines, end='')
return

while os.path.exists(status_file_path):
line = status.readline().rstrip()
# If progress bar exceeds it will switch to the red color. In this case we could stop the monitoring process.
if line.startswith("\033[91m["):
print(line)
break

sys.stdout.write("\r" + line)
sys.stdout.flush()
time.sleep(1)

for line in status.readlines():
print(line, end='')


def show_fail_motd(logfile_path: PathType, util_name: str) -> None:
motd.add_finish_ssh_login_message(f"""
Expand Down
Loading