diff --git a/docs/en_US/release_notes_9_5.rst b/docs/en_US/release_notes_9_5.rst index 3ce9d32c5..a6d0c5412 100644 --- a/docs/en_US/release_notes_9_5.rst +++ b/docs/en_US/release_notes_9_5.rst @@ -29,5 +29,6 @@ Bug fixes ********* | `Issue #6118 `_ - Improved PL/pgSQL code folding and support nested blocks. + | `Issue #7466 `_ - Fixed an issue where utilities such as pg_dump and pg_restore failed to log error messages when required dependency files were missing. | `Issue #8032 `_ - Fixed an issue where the Schema Diff Tool incorrectly reported differences due to variations in the order of the privileges. | `Issue #8691 `_ - Fixed an issue in the query tool where using multiple cursors to copy text resulted in only the first line being copied. diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py index 4dbf5d8f0..4edda6f91 100644 --- a/web/pgadmin/misc/bgprocess/processes.py +++ b/web/pgadmin/misc/bgprocess/processes.py @@ -25,7 +25,8 @@ import shutil from pgadmin.utils import u_encode, file_quote, fs_encoding, \ get_complete_file_path, get_storage_directory, IS_WIN -from pgadmin.utils.constants import KERBEROS +from pgadmin.utils.constants import (KERBEROS, UTILITIES_ARRAY, + BG_PROCESS_ERROR_MSGS) from pgadmin.utils.locker import ConnectionLocker from pgadmin.utils.preferences import Preferences @@ -45,6 +46,26 @@ PROCESS_TERMINATED = 3 PROCESS_NOT_FOUND = _("Could not find a process with the specified ID.") +def get_error_msg(cmd, error_code): + """ + This function is used to get the error message based on exit code. + """ + error_str = '' + # Get the Utility from the cmd. + for utility in UTILITIES_ARRAY: + if utility in cmd: + error_str = utility + _(': error: ') + break + + try: + error_str = error_str + BG_PROCESS_ERROR_MSGS[error_code] + except KeyError: + error_str = (error_str + _('utility failed with exit code: ') + + str(error_code)) + + return error_str + + def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'): """ Generate the current time string in the given format. @@ -608,6 +629,12 @@ class BatchProcess: 'process_state': self.process_state } + # Get the error message based on exit code. + if err_completed and self.ecode != 0: + err_msg = get_error_msg(self.cmd, self.ecode) + # This should be the last line as added 'Z' for sorting. + stderr.append(['Z', err_msg]) + return { 'out': { 'pos': out, diff --git a/web/pgadmin/utils/constants.py b/web/pgadmin/utils/constants.py index 2ee659441..ed2941ec8 100644 --- a/web/pgadmin/utils/constants.py +++ b/web/pgadmin/utils/constants.py @@ -115,7 +115,13 @@ BINARY_PATHS = { ] } -UTILITIES_ARRAY = ['pg_dump', 'pg_dumpall', 'pg_restore', 'psql'] +UTILITIES_ARRAY = ['pg_dumpall', 'pg_dump', 'pg_restore', 'psql'] + +BG_PROCESS_ERROR_MSGS = { + 3221225781: gettext('Unable to find a dll needed by the utility. Ensure ' + '.dll files needed by the utility are in the same ' + 'folder as your executable.') +} ENTER_EMAIL_ADDRESS = "Email address: " USER_NOT_FOUND = gettext("The specified user ID (%s) could not be found.")