Skip to content

Commit

Permalink
- Switched exception to IOError as FileNotFoundError no available.
Browse files Browse the repository at this point in the history
- Added exit(1) to stop script.
  • Loading branch information
Keir Whitlock authored and venth committed Apr 14, 2018
1 parent d687a70 commit 7161e48
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aws_adfs/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,17 @@ def _file_user_credentials(profile, authfile):

try:
if len(config.read(authfile)) == 0:
raise FileNotFoundError(authfile)
except FileNotFoundError as e:
raise IOError(authfile)
except IOError as e:
print('Auth file ({}) not found'.format(e))
sys.exit(1)

try:
username = config.get(profile, "username")
password = config.get(profile, "password")
except configparser.NoSectionError:
print('Auth file section header ({}) not found.'.format(profile))
sys.exit(1)


return username, password
Expand Down

0 comments on commit 7161e48

Please sign in to comment.