Merge pull request #19079 from Lendar/fix-s3-put

Fix PUT/DELETE in s3.query
This commit is contained in:
Joseph Hall 2014-12-18 08:47:15 -07:00
commit 74bd7f08d8

View File

@ -153,6 +153,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
try:
result = requests.request(method, requesturl, headers=headers,
data=data,
verify=verify_ssl)
response = result.content
except requests.exceptions.HTTPError as exc:
@ -165,7 +166,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
log.debug('S3 Response Status Code: {0}'.format(result.status_code))
if method == 'PUT':
if result.getcode() == 200:
if result.status_code == 200:
if local_file:
log.debug('Uploaded from {0} to {1}'.format(local_file, path))
else:
@ -175,14 +176,14 @@ def query(key, keyid, method='GET', params=None, headers=None,
log.debug('Failed to upload from {0} to {1}: {2}'.format(
local_file,
path,
result.getcode(),
result.status_code,
))
else:
log.debug('Failed to create bucket {0}'.format(bucket))
return
if method == 'DELETE':
if str(result.getcode()).startswith('2'):
if str(result.status_code).startswith('2'):
if path:
log.debug('Deleted {0} from bucket {1}'.format(path, bucket))
else:
@ -192,7 +193,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
log.debug('Failed to delete {0} from bucket {1}: {2}'.format(
path,
bucket,
result.getcode(),
result.status_code,
))
else:
log.debug('Failed to delete bucket {0}'.format(bucket))