From 0a1405847971af36fbac1819d3889dbd6f9f33ae Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Wed, 10 Apr 2024 15:08:02 +0300 Subject: [PATCH] Highlight that the --revert option can be utilized in the event of a conversion failure --- pleskdistup/main.py | 11 +++++++++-- pleskdistup/messages.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pleskdistup/main.py b/pleskdistup/main.py index 142a706..a50b93b 100644 --- a/pleskdistup/main.py +++ b/pleskdistup/main.py @@ -123,6 +123,7 @@ def handle_error( logfile_path: PathType, util_name: str, status_flag_path: PathType, + phase: Phase, upgrader: DistUpgrader, ) -> None: print() @@ -134,7 +135,13 @@ def handle_error( print(line, end='') error_message += line - print(messages.FAIL_MESSAGE_TAIL.format(util_name=util_name, logfile_path=logfile_path), end='') + # When adding something to the additional_message, remember to include '\n' at the beginning. + # This is because the FAIL_MESSAGE_TAIL contains the additional_message at the end of the previous line, + # preventing an empty line if there is nothing inside the additional_message. + additional_message = "" + if phase is Phase.CONVERT: + additional_message = f"\nTo revert the server to its original state, call '{util_name} --revert'." + print(messages.FAIL_MESSAGE_TAIL.format(util_name=util_name, logfile_path=logfile_path, additional_message=additional_message), end='') plesk.send_error_report(error_message) plesk.send_conversion_status(False, str(status_flag_path)) @@ -240,7 +247,7 @@ def do_convert( print(messages.FINISH_RESTART_MESSAGE, end='') systemd.do_reboot() except Exception as e: - handle_error(str(e), logfile_path, util_name, options.status_flag_path, upgrader) + handle_error(str(e), logfile_path, util_name, options.status_flag_path, options.phase, upgrader) return 1 else: for stage_id, actions in actions_map.items(): diff --git a/pleskdistup/messages.py b/pleskdistup/messages.py index 4429e89..87d8788 100644 --- a/pleskdistup/messages.py +++ b/pleskdistup/messages.py @@ -34,7 +34,7 @@ \033[91m************************************************************************************** The dist-ugrade process has failed. See the {logfile_path} file for more information. The last 100 lines of the file are shown above. -For assistance, call '{util_name} --prepare-feedback' and follow the instructions. +For assistance, call '{util_name} --prepare-feedback' and follow the instructions.{additional_message} **************************************************************************************\033[0m """