Skip to content

Commit

Permalink
v5.10.x Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
terrelsa13 committed Jan 19, 2025
1 parent 8a5983f commit c4e328b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
14 changes: 13 additions & 1 deletion mumc_modules/mumc_config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,36 @@ def build_configuration_file(the_dict,orig_dict={}):
print('----------------------------------------------------------------------------------------')

print('----------------------------------------------------------------------------------------')
print('000')

#set REMOVE_FILES
the_dict['advanced_settings']['REMOVE_FILES']=False
print('001')

print('----------------------------------------------------------------------------------------')

print('002')

#Build and save new yaml config file
if (not the_dict['advanced_settings']['UPDATE_CONFIG']):
print('003')
yaml_configurationBuilder(the_dict)
print('004')

try:
print('005')
the_dict=getIsAnyMediaEnabled(the_dict)
print('006')

if (the_dict['all_media_disabled']):
print('007')
print_all_media_disabled(the_dict)
print('008')

print('009')
strings_list_to_print=built_new_config_not_setup_to_delete_media('',the_dict)
print('00A')
print_byType(strings_list_to_print,the_dict['advanced_settings']['console_controls']['warnings']['script']['show'],the_dict,the_dict['formatting'])
print('00B')

#the exception
except (AttributeError, ModuleNotFoundError):
Expand Down
42 changes: 42 additions & 0 deletions mumc_modules/mumc_config_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def cannotFindConfig(init_dict,cmdopt_dict):
print_containerized_config_missing(init_dict)
time.sleep(5)
importConfig(init_dict,cmdopt_dict)
print('00C')
else:
print('00D')
#config not found
#or
#config found; but missing DEBUG or server_brand options; automatically start to rebuild new config
Expand All @@ -28,132 +30,172 @@ def cannotFindConfig(init_dict,cmdopt_dict):
init_dict['mumc_path']=cmdopt_dict['altConfigPath']
init_dict['config_file_name_yaml']=cmdopt_dict['altConfigFileExt']
build_configuration_file(init_dict)
print('00E')
#exit gracefully
sys.exit(0)


#verify specified variables are avaialbe in the config
def assignVarTest(init_dict,cmdopt_dict,cfg):
print('00F')
try:
print('00G')
#check if mumc_config.yaml exists but is blank
if (not (cfg == None)):
print('00H')
#removing any of the test variables from mumc_config.yaml will cause script to rebuild a new config.yaml
#try assigning the below variables from the mumc_config.yaml file
#if any do not exist go to except and rebuild the mumc_config.yaml file
init_dict['version']=cfg['version']
init_dict['DEBUG']=cfg['DEBUG']
else:
print('00I')
raise ModuleNotFoundError

except (AttributeError, ModuleNotFoundError, KeyError):
print('00J')
cannotFindConfig(init_dict,cmdopt_dict)

return init_dict


def importConfig(init_dict,cmdopt_dict):
try:
print('00K')
#Attempt to import the alternate config file as cfg
#Check for the .py extension and no spaces or periods in the module name
if (cmdopt_dict['altConfigInfo']):
print('00L')
#Insert alternate config to path at the top of the path list so it can be searched and imported first
#We want the alternate config path to be searched first incase the the alternate config is also named mumc_config.yaml
#Searching the alternate config path first will allow the alternate config file to be found first
add_to_PATH(cmdopt_dict['altConfigPath'],0)
print('00M')

#check if yaml config
if ((getFileExtension(cmdopt_dict['altConfigPath'] / cmdopt_dict['altConfigFileExt']) == '.yaml') or
(getFileExtension(cmdopt_dict['altConfigPath'] / cmdopt_dict['altConfigFileExt']) == '.yml')):
print('00N')
#open alternate yaml config
with open(cmdopt_dict['altConfigPath'] / cmdopt_dict['altConfigFileExt'], 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)
print('00O')

init_dict['mumc_path']=cmdopt_dict['altConfigPath']
init_dict['config_file_name_yaml']=cmdopt_dict['altConfigFileExt']
print('00P')

#check if legacy config
else: #if (getFileExtension(cmdopt_dict['altConfigPath'] / cmdopt_dict['altConfigFileExt']) == '.py'):
print('00Q')
#Cannot do a direct import using a variable; use the importlib.import_module instead
#Also cannot import the whole path; add the path to path then import by filename
cfg = importlib.import_module(cmdopt_dict['altConfigFileNoExt'],cmdopt_dict['altConfigInfo'])

#run a config check on the legacy mumc_config.py before converting to mumc_config.yaml
legacy_dict=cfgCheckLegacy(cfg,init_dict)

print('00R')
#function to convert legacy config to mumc_config.yaml
convert_legacyConfigToYAML(cfg,cmdopt_dict['altConfigPath'],cmdopt_dict['altConfigFileNoExt'])
print('00S')

with open(cmdopt_dict['altConfigPath'] / cmdopt_dict['altConfigFileNoExt'] + '.yaml', 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)
print('00T')

init_dict['mumc_path']=cmdopt_dict['altConfigPath']
init_dict['config_file_name_yaml']=cmdopt_dict['altConfigFileNoExt'] + '.yaml'

print('00U')
#make sure a few of the necessary config variables are there
init_dict=assignVarTest(init_dict,cmdopt_dict,cfg)

else:
print('00V')
if (doesFileExist(init_dict['mumc_path'] / init_dict['config_file_name_yaml'])):
print('00W')
#try importing the mumc_config.yaml file
#if mumc_config.yaml file does not exist try importing the config/mumc_config.py file
with open(init_dict['mumc_path'] / init_dict['config_file_name_yaml'], 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)
print('00X')

#make sure a few of the necessary config variables are there
init_dict=assignVarTest(init_dict,cmdopt_dict,cfg)
elif (doesFileExist(init_dict['mumc_path'] / init_dict['config_file_name_yml'])):
print('00Y')
#try importing the mumc_config.yaml file
#if mumc_config.yaml file does not exist try importing the config/mumc_config.py file
with open(init_dict['mumc_path'] / init_dict['config_file_name_yml'], 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)

print('00Z')
init_dict['config_file_name_yaml']=init_dict['config_file_name_yml']

#make sure a few of the necessary config variables are there
init_dict=assignVarTest(init_dict,cmdopt_dict,cfg)
print('00!')
elif (doesFileExist(init_dict['mumc_path_config_dir'] / init_dict['config_file_name_yaml'])):
print('00@')
#try importing the config/mumc_config.yaml file
#if config/mumc_config.yaml file does not exist try importing the legacy mumc_config.py file
#with open(init_dict['mumc_path'] / init_dict['config_file_name_yaml'], 'r') as mumc_config_yaml:
with open(init_dict['mumc_path_config_dir'] / init_dict['config_file_name_yaml'], 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)
print('00#')

init_dict['mumc_path']=init_dict['mumc_path_config_dir']

#make sure a few of the necessary config variables are there
init_dict=assignVarTest(init_dict,cmdopt_dict,cfg)
print('00$')
elif (doesFileExist(init_dict['mumc_path_config_dir'] / init_dict['config_file_name_yml'])):
print('00%')
#try importing the config/mumc_config.yaml file
#if config/mumc_config.yaml file does not exist try importing the legacy mumc_config.py file
#with open(init_dict['mumc_path'] / init_dict['config_file_name_yaml'], 'r') as mumc_config_yaml:
with open(init_dict['mumc_path_config_dir'] / init_dict['config_file_name_yml'], 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)
print('00^')

init_dict['mumc_path']=init_dict['mumc_path_config_dir']
init_dict['config_file_name_yaml']=init_dict['config_file_name_yml']
print('00&')


#make sure a few of the necessary config variables are there
init_dict=assignVarTest(init_dict,cmdopt_dict,cfg)
print('00*')
elif (doesFileExist(init_dict['mumc_path'] / init_dict['config_file_name_py'])):
print('00(')
#try importing the mumc_config.py file
#if mumc_config.py file does not exist go to except and create one
import mumc_config as cfg

#run a config check on the legacy mumc_config.py before converting to mumc_config.yaml
legacy_dict=cfgCheckLegacy(cfg,init_dict)
print('00)')

#convert legacy mumc_config.py to mumc_config.yaml; output is mumc_config.yaml
convert_legacyConfigToYAML(legacy_dict,init_dict['mumc_path'],init_dict['config_file_name_no_ext'])
print('00-')

with open(init_dict['mumc_path'] / init_dict['config_file_name_yaml'], 'r') as mumc_config_yaml:
cfg = yaml.safe_load(mumc_config_yaml)

print('00_')
#make sure a few of the necessary config variables are there
init_dict=assignVarTest(init_dict,cmdopt_dict,cfg)
print('00=')
else:
print('00+')
cannotFindConfig(init_dict,cmdopt_dict)
print('00[')

except (AttributeError, ModuleNotFoundError, KeyError):
print('00]')
cannotFindConfig(init_dict,cmdopt_dict)
print('00{')

return cfg,init_dict
2 changes: 1 addition & 1 deletion mumc_modules/mumc_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#Get the current script version
def get_script_version():
return '5.10.3-alpha'
return '5.10.4-alpha'


#Get the min config version
Expand Down

0 comments on commit c4e328b

Please sign in to comment.