Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1361 and #1027 - update to python 3.2+ API (existing code calls removed API) #1365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions S3/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def __init__(self, configfile = None, access_key=None, secret_key=None, access_t
try:
self.read_config_file(configfile)
except IOError:
if 'AWS_CREDENTIAL_FILE' in os.environ or 'AWS_PROFILE' in os.environ:
if 'AWS_SHARED_CREDENTIALS_FILE' in os.environ or 'AWS_CREDENTIAL_FILE' in os.environ or 'AWS_PROFILE' in os.environ:
self.aws_credential_file()

# override these if passed on the command-line
Expand Down Expand Up @@ -439,7 +439,8 @@ def role_refresh(self):
def aws_credential_file(self):
try:
aws_credential_file = os.path.expanduser('~/.aws/credentials')
credential_file_from_env = os.environ.get('AWS_CREDENTIAL_FILE')
credential_file_from_env = os.environ.get('AWS_SHARED_CREDENTIALS_FILE') \
or os.environ.get('AWS_CREDENTIAL_FILE')
if credential_file_from_env and \
os.path.isfile(credential_file_from_env):
aws_credential_file = base_unicodise(credential_file_from_env)
Expand All @@ -454,17 +455,15 @@ def aws_credential_file(self):
config_string = fp.read()
try:
try:
# readfp is replaced by read_file in python3,
# but so far readfp it is still available.
config.readfp(io.StringIO(config_string))
config.read_file(io.StringIO(config_string))
except MissingSectionHeaderError:
# if header is missing, this could be deprecated
# credentials file format as described here:
# https://blog.csanchez.org/2011/05/
# then do the hacky-hack and add default header
# to be able to read the file with PyConfigParser()
config_string = u'[default]\n' + config_string
config.readfp(io.StringIO(config_string))
config.read_file(io.StringIO(config_string))
except ParsingError as exc:
raise ValueError(
"Error reading aws_credential_file "
Expand Down