Fixed requests HTTPError handler, it was still in urllib2 style

This commit is contained in:
Petr Messner 2015-11-05 23:29:43 +01:00 committed by rallytime
parent 1a4cd6002f
commit a3216f813d

View File

@ -122,10 +122,10 @@ def query(key, keyid, method='GET', params=None, headers=None,
verify=verify_ssl)
response = result.content
except requests.exceptions.HTTPError as exc:
log.error('There was an error::')
if hasattr(exc, 'code') and hasattr(exc, 'msg'):
log.error(' Code: {0}: {1}'.format(exc.code, exc.msg))
log.error(' Content: \n{0}'.format(exc.read()))
log.error('Failed to {0} {1}::'.format(method, requesturl))
log.error(' Exception: {0}'.format(exc))
if exc.response:
log.error(' Response content: {0}'.format(exc.response.content))
return False
log.debug('S3 Response Status Code: {0}'.format(result.status_code))