mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that DATA_DIR dependent folders/files are automatically created inside the specified DATA_DIR if they are not specified separately in the configuration file.. #5513
This commit is contained in:
@@ -835,16 +835,33 @@ AUTO_DISCOVER_SERVERS = True
|
||||
##########################################################################
|
||||
# Local config settings
|
||||
##########################################################################
|
||||
# User configs loaded from config_local, config_distro etc.
|
||||
user_config_settings = {}
|
||||
|
||||
|
||||
# Function to Extract settings from config_local, config_distro etc.
|
||||
def get_variables_from_module(module_name):
|
||||
module = globals().get(module_name, None)
|
||||
variables = {}
|
||||
if module:
|
||||
variables = {key: value for key, value in module.__dict__.items()
|
||||
if not (key.startswith('__') or key.startswith('_'))}
|
||||
return variables
|
||||
|
||||
|
||||
# Load distribution-specific config overrides
|
||||
try:
|
||||
from config_distro import *
|
||||
import config_distro
|
||||
config_distro_settings = get_variables_from_module('config_distro')
|
||||
user_config_settings.update(config_distro_settings)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Load local config overrides
|
||||
try:
|
||||
from config_local import *
|
||||
import config_local
|
||||
config_local_settings = get_variables_from_module('config_local')
|
||||
user_config_settings.update(config_local_settings)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -860,10 +877,29 @@ elif sys.platform.startswith('darwin'):
|
||||
if os.path.exists(system_config_dir + '/config_system.py'):
|
||||
try:
|
||||
sys.path.insert(0, system_config_dir)
|
||||
from config_system import *
|
||||
import config_system
|
||||
config_system_settings = get_variables_from_module('config_system')
|
||||
user_config_settings.update(config_system_settings)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Update settings for 'LOG_FILE', 'SQLITE_PATH', 'SESSION_DB_PATH',
|
||||
# 'AZURE_CREDENTIAL_CACHE_DIR', 'KERBEROS_CCACHE_DIR', 'STORAGE_DIR'
|
||||
# of DATA_DIR is user defined
|
||||
data_dir_dependent_settings = ['LOG_FILE', 'SQLITE_PATH', 'SESSION_DB_PATH',
|
||||
'AZURE_CREDENTIAL_CACHE_DIR',
|
||||
'KERBEROS_CCACHE_DIR', 'STORAGE_DIR']
|
||||
|
||||
if 'DATA_DIR' in user_config_settings:
|
||||
for setting in data_dir_dependent_settings:
|
||||
if setting not in user_config_settings:
|
||||
data_dir = user_config_settings['DATA_DIR']
|
||||
file_dir_name = os.path.basename(locals().get(setting))
|
||||
locals().update({setting: os.path.join(data_dir, file_dir_name)})
|
||||
|
||||
# Finally update config user configs
|
||||
locals().update(user_config_settings)
|
||||
|
||||
# Override DEFAULT_SERVER value from environment variable.
|
||||
if 'PGADMIN_CONFIG_DEFAULT_SERVER' in os.environ:
|
||||
DEFAULT_SERVER = os.environ['PGADMIN_CONFIG_DEFAULT_SERVER']
|
||||
|
||||
Reference in New Issue
Block a user