mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed import/export servers issue reported during testing.
This commit is contained in:
parent
e43a87da09
commit
7fe1d89891
@ -451,7 +451,9 @@ def dump_database_servers(output_file, selected_servers,
|
|||||||
object_dict["Servers"] = server_dict
|
object_dict["Servers"] = server_dict
|
||||||
|
|
||||||
# retrieve storage directory path
|
# retrieve storage directory path
|
||||||
storage_manager_path = get_storage_directory()
|
storage_manager_path = None
|
||||||
|
if not from_setup:
|
||||||
|
storage_manager_path = get_storage_directory(user)
|
||||||
|
|
||||||
# generate full path of file
|
# generate full path of file
|
||||||
file_path = unquote(output_file)
|
file_path = unquote(output_file)
|
||||||
@ -470,7 +472,7 @@ def dump_database_servers(output_file, selected_servers,
|
|||||||
|
|
||||||
# write to file
|
# write to file
|
||||||
file_content = json.dumps(object_dict, indent=4)
|
file_content = json.dumps(object_dict, indent=4)
|
||||||
error_str = gettext("Error: {0}")
|
error_str = "Error: {0}"
|
||||||
try:
|
try:
|
||||||
with open(file_path, 'w') as output_file:
|
with open(file_path, 'w') as output_file:
|
||||||
output_file.write(file_content)
|
output_file.write(file_content)
|
||||||
@ -481,8 +483,8 @@ def dump_database_servers(output_file, selected_servers,
|
|||||||
err_msg = error_str.format(e.strerror)
|
err_msg = error_str.format(e.strerror)
|
||||||
return _handle_error(err_msg, from_setup)
|
return _handle_error(err_msg, from_setup)
|
||||||
|
|
||||||
msg = "Configuration for %s servers dumped to %s." % \
|
msg = "Configuration for %s servers dumped to %s" % \
|
||||||
(servers_dumped, output_file)
|
(servers_dumped, output_file.name)
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
return True, msg
|
return True, msg
|
||||||
@ -557,8 +559,15 @@ def load_database_servers(input_file, selected_servers,
|
|||||||
load_user=current_user, from_setup=False):
|
load_user=current_user, from_setup=False):
|
||||||
"""Load server groups and servers.
|
"""Load server groups and servers.
|
||||||
"""
|
"""
|
||||||
|
user = _does_user_exist(load_user, from_setup)
|
||||||
|
if user is None:
|
||||||
|
return False, USER_NOT_FOUND % load_user
|
||||||
|
|
||||||
# retrieve storage directory path
|
# retrieve storage directory path
|
||||||
storage_manager_path = get_storage_directory()
|
storage_manager_path = None
|
||||||
|
if not from_setup:
|
||||||
|
storage_manager_path = get_storage_directory(user)
|
||||||
|
|
||||||
# generate full path of file
|
# generate full path of file
|
||||||
file_path = unquote(input_file)
|
file_path = unquote(input_file)
|
||||||
if storage_manager_path:
|
if storage_manager_path:
|
||||||
@ -580,10 +589,6 @@ def load_database_servers(input_file, selected_servers,
|
|||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
user = _does_user_exist(load_user, from_setup)
|
|
||||||
if user is None:
|
|
||||||
return False, USER_NOT_FOUND % load_user
|
|
||||||
|
|
||||||
user_id = user.id
|
user_id = user.id
|
||||||
# Counters
|
# Counters
|
||||||
groups_added = 0
|
groups_added = 0
|
||||||
|
@ -16,7 +16,7 @@ from flask_security import current_user
|
|||||||
from werkzeug.exceptions import InternalServerError
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
|
|
||||||
def get_storage_directory():
|
def get_storage_directory(user=current_user):
|
||||||
import config
|
import config
|
||||||
if config.SERVER_MODE is not True:
|
if config.SERVER_MODE is not True:
|
||||||
return None
|
return None
|
||||||
@ -44,7 +44,7 @@ def get_storage_directory():
|
|||||||
|
|
||||||
return ret_un
|
return ret_un
|
||||||
|
|
||||||
username = _preprocess_username(current_user.username.split('@')[0])
|
username = _preprocess_username(user.username.split('@')[0])
|
||||||
|
|
||||||
# Figure out the old-style storage directory name
|
# Figure out the old-style storage directory name
|
||||||
old_storage_dir = os.path.join(
|
old_storage_dir = os.path.join(
|
||||||
@ -53,7 +53,7 @@ def get_storage_directory():
|
|||||||
username
|
username
|
||||||
)
|
)
|
||||||
|
|
||||||
username = _preprocess_username(current_user.username)
|
username = _preprocess_username(user.username)
|
||||||
|
|
||||||
# Figure out the new style storage directory name
|
# Figure out the new style storage directory name
|
||||||
storage_dir = os.path.join(
|
storage_dir = os.path.join(
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
and settings database."""
|
and settings database."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import builtins
|
import builtins
|
||||||
|
Loading…
Reference in New Issue
Block a user