Skip to content

Commit

Permalink
fix of HTTP errors, version to 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksMat committed Feb 14, 2018
1 parent f3d85fa commit 4867fc8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sentinelhub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
from .time_utils import next_date, prev_date, get_current_date


__version__ = "1.0.7"
__version__ = "1.0.8"
9 changes: 3 additions & 6 deletions sentinelhub/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ def _is_temporal_problem(exception):
:rtype: bool
"""
return isinstance(exception, (requests.ConnectionError, requests.ConnectTimeout, requests.ReadTimeout,
requests.Timeout))\
or (isinstance(exception, requests.HTTPError) and
exception.response.status_code != requests.status_codes.codes.BAD_REQUEST)
requests.Timeout))


def _create_download_failed_message(exception):
Expand All @@ -257,16 +255,15 @@ def _create_download_failed_message(exception):
else:
message += '\nThere might be a problem in connection or the server failed to process ' \
'your request. Please try again.'
elif isinstance(exception, requests.HTTPError) and \
exception.response.status_code == requests.status_codes.codes.BAD_REQUEST:
elif isinstance(exception, requests.HTTPError):
try:
server_message = ''
for elem in decode_data(exception.response, MimeType.XML):
if 'ServiceException' in elem.tag:
server_message += elem.text.strip('\n\t ')
except ElementTree.ParseError:
server_message = exception.response.text
message += '\nYour request is incorrect, server response: "{}"'.format(server_message)
message += '\nServer response: "{}"'.format(server_message)

return message

Expand Down

0 comments on commit 4867fc8

Please sign in to comment.