mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 20:11:20 +00:00
Bootstrap: Fixes not using newly created config files
If the $WA_USER_DIRECTORY folder is not present on the users system it is automatically created and a default config.py file created. Previously this newly created file would not be loaded into WA causing it to crash.
This commit is contained in:
parent
8dcf1ba6a5
commit
4c0d3f8d20
@ -152,7 +152,8 @@ def init_environment(env_root, dep_dir, extension_paths, overwrite_existing=Fals
|
||||
os.makedirs(env_root)
|
||||
with open(os.path.join(_this_dir, '..', 'config_example.py')) as rf:
|
||||
text = re.sub(r'""".*?"""', '', rf.read(), 1, re.DOTALL)
|
||||
with open(os.path.join(_env_root, 'config.py'), 'w') as wf:
|
||||
config_path = os.path.join(env_root, 'config.py')
|
||||
with open(config_path, 'w') as wf:
|
||||
wf.write(text)
|
||||
|
||||
os.makedirs(dep_dir)
|
||||
@ -173,6 +174,7 @@ def init_environment(env_root, dep_dir, extension_paths, overwrite_existing=Fals
|
||||
os.chown(os.path.join(root, d), uid, gid)
|
||||
for f in files: # pylint: disable=W0621
|
||||
os.chown(os.path.join(root, f), uid, gid)
|
||||
return config_path
|
||||
|
||||
|
||||
_env_root = os.getenv('WA_USER_DIRECTORY', os.path.join(_user_home, '.workload_automation'))
|
||||
@ -190,7 +192,8 @@ for filename in ['config.py', 'config.yaml']:
|
||||
_env_configs.append(filepath)
|
||||
|
||||
if not os.path.isdir(_env_root):
|
||||
init_environment(_env_root, _dep_dir, _extension_paths)
|
||||
cfg_path = init_environment(_env_root, _dep_dir, _extension_paths)
|
||||
_env_configs.append(cfg_path)
|
||||
elif not _env_configs:
|
||||
filepath = os.path.join(_env_root, 'config.py')
|
||||
with open(os.path.join(_this_dir, '..', 'config_example.py')) as f:
|
||||
|
Loading…
x
Reference in New Issue
Block a user