From e61eda33d74b234e248ce18105eb3902c9eab495 Mon Sep 17 00:00:00 2001 From: Hugo Maingonnat Date: Mon, 2 Dec 2019 17:34:06 +0100 Subject: [PATCH 1/2] raising custom exception for credentials --- deepomatic/api/exceptions.py | 5 +++++ deepomatic/api/http_helper.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/deepomatic/api/exceptions.py b/deepomatic/api/exceptions.py index 6470c98..109f739 100644 --- a/deepomatic/api/exceptions.py +++ b/deepomatic/api/exceptions.py @@ -32,6 +32,11 @@ class DeepomaticException(Exception): def __init__(self, msg): super(DeepomaticException, self).__init__(msg) +############################################################################### + +class CredentialsNotFound(DeepomaticException): + pass + ############################################################################### diff --git a/deepomatic/api/http_helper.py b/deepomatic/api/http_helper.py index ba055f3..beb2656 100644 --- a/deepomatic/api/http_helper.py +++ b/deepomatic/api/http_helper.py @@ -30,7 +30,8 @@ import requests from deepomatic.api.exceptions import (BadStatus, ServerError, - ClientError, DeepomaticException) + ClientError, DeepomaticException, + CredentialsNotFound) from deepomatic.api.http_retry import HTTPRetry from deepomatic.api.version import __title__, __version__ from requests.structures import CaseInsensitiveDict @@ -76,7 +77,7 @@ def __init__(self, app_id=None, api_key=None, verify_ssl=None, if api_key is None: api_key = os.getenv('DEEPOMATIC_API_KEY') if api_key is None: - raise DeepomaticException("Please specify 'api_key' either by passing it to the client" + raise CredentialsNotFound("Please specify 'api_key' either by passing it to the client" " or by defining the DEEPOMATIC_API_KEY environment variable.") if version is None or version == '': From ae7402f4a5b5db7650f4e58207bf6a8d01f612ac Mon Sep 17 00:00:00 2001 From: Hugo Maingonnat Date: Mon, 2 Dec 2019 18:04:20 +0100 Subject: [PATCH 2/2] flake --- deepomatic/api/exceptions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/deepomatic/api/exceptions.py b/deepomatic/api/exceptions.py index 109f739..97df5e4 100644 --- a/deepomatic/api/exceptions.py +++ b/deepomatic/api/exceptions.py @@ -34,6 +34,7 @@ def __init__(self, msg): ############################################################################### + class CredentialsNotFound(DeepomaticException): pass