Skip to content

Commit b43b429

Browse files
committed
Fix tests if ~/.aws/shell/ doesn't exist.
Fixes issues with test_keys.py and test_config.py. Creates the directory that will contain the awsshellrc config file if it doesn't yet exist. Once it exists, continues with copying the template config file to ~/.aws/shell/awsshellrc.
1 parent 66b7ecc commit b43b429

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

awsshell/config.py

+8
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ def _copy_template_to_config(self, template_path,
7575
:type overwrite: bool
7676
:param overwrite: (Optional) Determines whether to overwrite the
7777
existing config file, if it exists.
78+
79+
:raises: :class:`OSError <exceptions.OSError>`
7880
"""
7981
expanded_config_path = os.path.expanduser(config_path)
8082
if not overwrite and os.path.isfile(config_path):
8183
return
8284
else:
85+
try:
86+
config_path_dir_name = os.path.dirname(config_path)
87+
os.makedirs(config_path_dir_name)
88+
except OSError:
89+
if not os.path.isdir(config_path_dir_name):
90+
raise
8391
shutil.copyfile(template_path, config_path)

0 commit comments

Comments
 (0)