1010import os
1111import sys
1212import keyring
13- import email_validator
13+ import importlib . util
1414
1515# User configs loaded from config_local, config_distro etc.
1616custom_config_settings = {}
1717
18-
1918# Function to Extract settings from config_local, config_distro etc.
2019def get_variables_from_module (module_name ):
2120 module = globals ().get (module_name , None )
@@ -27,6 +26,17 @@ def get_variables_from_module(module_name):
2726 return variables
2827
2928
29+ # Function to load config_distro at custom path
30+ def import_module_from_path (module_name , file_path ):
31+ # Create a module spec
32+ spec = importlib .util .spec_from_file_location (module_name , file_path )
33+ # Create the module based on the spec
34+ module = importlib .util .module_from_spec (spec )
35+ # Execute the module (this loads it)
36+ spec .loader .exec_module (module )
37+ return module
38+
39+
3040def validate_config_variable (key , value ):
3141 boolean_keys = ['SERVER_MODE' , 'ENHANCED_COOKIE_PROTECTION' ,
3242 'SUPPORT_SSH_TUNNEL' , 'ALLOW_SAVE_TUNNEL_PASSWORD' ,
@@ -47,7 +57,10 @@ def validate_config_variable(key, value):
4757
4858# Load distribution-specific config overrides
4959try :
50- import config_distro
60+ if 'CONFIG_DISTRO_FILE_PATH' in os .environ :
61+ config_distro_path = os .environ ['CONFIG_DISTRO_FILE_PATH' ]
62+ config_distro = import_module_from_path ('config_distro' ,
63+ config_distro_path )
5164 config_distro_settings = get_variables_from_module ('config_distro' )
5265 custom_config_settings .update (config_distro_settings )
5366except ImportError :
0 commit comments