1) Added logic to set the appropriate default binary path if DEFAULT_BINARY_PATH is

set in the config and the user not updated the preferences.
2) Remove 'gpdb' from DEFAULT_BINARY_PATH.
3) Fixed API test cases. 

refs #5370
This commit is contained in:
Akshay Joshi
2021-06-07 20:36:34 +05:30
parent 065a3aa2f5
commit 07eb541806
8 changed files with 112 additions and 38 deletions

View File

@@ -16,7 +16,7 @@ from pgadmin.utils import PgAdminModule
from pgadmin.utils.csrf import pgCSRFProtect
from pgadmin.utils.session import cleanup_session_files
from pgadmin.misc.themes import get_all_themes
from pgadmin.utils.constants import MIMETYPE_APP_JS
from pgadmin.utils.constants import MIMETYPE_APP_JS, UTILITIES_ARRAY
from pgadmin.utils.ajax import precondition_required, make_json_response
import config
import subprocess
@@ -191,23 +191,24 @@ def validate_binary_path():
version_str = ''
if 'utility_path' in data and data['utility_path'] is not None:
for utility in ['pg_dump', 'pg_dumpall', 'pg_restore', 'psql']:
for utility in UTILITIES_ARRAY:
full_path = os.path.abspath(
os.path.join(data['utility_path'],
(utility if os.name != 'nt' else
(utility + '.exe'))))
try:
result = subprocess.Popen([full_path, '--version'],
stdout=subprocess.PIPE)
except FileNotFoundError:
# Get the output of the '--version' command
version_string = subprocess.getoutput(full_path + ' --version')
# Get the version number by splitting the result string
version_string.split(") ", 1)[1].split('.', 1)[0]
except Exception:
version_str += "<b>" + utility + ":</b> " + \
"not found on the specified binary path.<br/>"
continue
# Replace the name of the utility from the result to avoid
# duplicate name.
result_str = \
result.stdout.read().decode("utf-8").replace(utility, '')
result_str = version_string.replace(utility, '')
version_str += "<b>" + utility + ":</b> " + result_str + "<br/>"
else: