Skip to content

Commit

Permalink
Guarantee credential file exists with section and read it
Browse files Browse the repository at this point in the history
  • Loading branch information
myoung34 committed May 15, 2018
1 parent a648a3b commit 61d292d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fedcred/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ def write_credentials(profile, creds):
creds_folder = os.path.dirname(aws_creds_path)
if not os.path.isdir(creds_folder):
os.makedirs(creds_folder)
if os.path.isfile(aws_creds_path):
config.read(aws_creds_path)
if not config.has_section(profile):
if not config.has_section(profile) or not os.path.isfile(aws_creds_path):
if profile == 'default':
configparser.DEFAULTSECT = profile
if sys.version_info.major == 3:
Expand All @@ -149,6 +147,9 @@ def write_credentials(profile, creds):
config.remove_option(profile, 'CREATE')
else:
config.add_section(profile)
with open(aws_creds_path, 'w') as configfile:
config.write(configfile)
config.read(aws_creds_path)

options = [
('aws_access_key_id', 'AccessKeyId'),
Expand Down

0 comments on commit 61d292d

Please sign in to comment.