From cf452bd1cb7e5e2e33996e3661fb1c186e5bc67f Mon Sep 17 00:00:00 2001 From: Sumit Maheshwari Date: Tue, 14 May 2019 15:54:51 +0530 Subject: [PATCH 1/4] SDK-XXX: Update readme --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 46a6ba14..3551794d 100644 --- a/README.rst +++ b/README.rst @@ -21,9 +21,9 @@ The SDK is available on `PyPI `_. From source ~~~~~~~~~~~ -* Download the source code: +* Get the source code: - - Either clone the project: ``git clone git@github.com:qubole/qds-sdk-py.git`` + - Either clone the project: ``git clone git@github.com:qubole/qds-sdk-py.git`` and checkout latest release tag from `Releases `_. - Or download one of the releases from https://github.com/qubole/qds-sdk-py/releases From e90918f630cee263fcddba5eb8d0e0f3d7e84984 Mon Sep 17 00:00:00 2001 From: Aaditya Sharma Date: Mon, 10 Jun 2019 14:27:48 +0530 Subject: [PATCH 2/4] Added new case for 449 --- qds_sdk/connection.py | 7 ++++++- qds_sdk/exception.py | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/qds_sdk/connection.py b/qds_sdk/connection.py index ede6c412..48fd10e4 100644 --- a/qds_sdk/connection.py +++ b/qds_sdk/connection.py @@ -152,9 +152,14 @@ def _handle_error(response): elif code == 422: sys.stderr.write(response.text + "\n") raise ResourceInvalid(response) - elif code in (449, 502, 503, 504): + elif code in (502, 503, 504): sys.stderr.write(response.text + "\n") raise RetryWithDelay(response) + elif code == 449: + message = "Data requested is unavailable. Retrying ..." + sys.stderr.write(response.text + "\n") + sys.stderr.write(message + "\n") + raise RetryWithDelay(response, message) elif 401 <= code < 500: sys.stderr.write(response.text + "\n") raise ClientError(response) diff --git a/qds_sdk/exception.py b/qds_sdk/exception.py index 5e361902..cc802725 100644 --- a/qds_sdk/exception.py +++ b/qds_sdk/exception.py @@ -11,8 +11,11 @@ def __init__(self, message, usage): class Error(Exception): """A general error derived from Exception.""" - def __init__(self, request): - Exception.__init__(self, request.text) + def __init__(self, request, message = ""): + response = request.text + if message: + response = message + Exception.__init__(self, response) self.request = request From 476780c31eb3e5cefa9df0cccf0437773469a636 Mon Sep 17 00:00:00 2001 From: Aaditya Sharma Date: Mon, 10 Jun 2019 15:12:38 +0530 Subject: [PATCH 3/4] Changes per comments --- qds_sdk/exception.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qds_sdk/exception.py b/qds_sdk/exception.py index cc802725..ef06a335 100644 --- a/qds_sdk/exception.py +++ b/qds_sdk/exception.py @@ -12,9 +12,7 @@ class Error(Exception): """A general error derived from Exception.""" def __init__(self, request, message = ""): - response = request.text - if message: - response = message + response = message if message else request.text Exception.__init__(self, response) self.request = request From 845ee5baecdaf31d7b4a423332f7b37b4cac9f7b Mon Sep 17 00:00:00 2001 From: Aaditya Sharma Date: Mon, 10 Jun 2019 15:19:33 +0530 Subject: [PATCH 4/4] Changes per cmnts --- qds_sdk/connection.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qds_sdk/connection.py b/qds_sdk/connection.py index 48fd10e4..0398acb5 100644 --- a/qds_sdk/connection.py +++ b/qds_sdk/connection.py @@ -156,10 +156,8 @@ def _handle_error(response): sys.stderr.write(response.text + "\n") raise RetryWithDelay(response) elif code == 449: - message = "Data requested is unavailable. Retrying ..." sys.stderr.write(response.text + "\n") - sys.stderr.write(message + "\n") - raise RetryWithDelay(response, message) + raise RetryWithDelay(response, "Data requested is unavailable. Retrying ...") elif 401 <= code < 500: sys.stderr.write(response.text + "\n") raise ClientError(response)