From 81adbdd8707415214207f8b9dff892ec738bf0ba Mon Sep 17 00:00:00 2001 From: Markus Koetter Date: Tue, 13 Apr 2021 07:44:24 +0200 Subject: [PATCH 1/2] introduce the AuthenticationError Exception --- lexicon/providers/aliyun.py | 4 ++-- lexicon/providers/aurora.py | 13 +++++-------- lexicon/providers/azure.py | 4 ++-- lexicon/providers/base.py | 6 +++++- lexicon/providers/cloudflare.py | 8 ++++---- lexicon/providers/cloudxns.py | 7 +++---- lexicon/providers/conoha.py | 6 +++--- lexicon/providers/constellix.py | 9 ++++----- lexicon/providers/dinahosting.py | 11 +++++------ lexicon/providers/directadmin.py | 10 ++++------ lexicon/providers/dnsimple.py | 10 +++++----- lexicon/providers/dnsmadeeasy.py | 4 ++-- lexicon/providers/dnspark.py | 4 ++-- lexicon/providers/dnspod.py | 4 ++-- lexicon/providers/dreamhost.py | 6 +++--- lexicon/providers/dynu.py | 6 +++--- lexicon/providers/easydns.py | 4 ++-- lexicon/providers/euserv.py | 14 ++++++-------- lexicon/providers/gandi.py | 4 ++-- lexicon/providers/gehirn.py | 4 ++-- lexicon/providers/glesys.py | 7 +++---- lexicon/providers/googleclouddns.py | 6 +++--- lexicon/providers/gransy.py | 6 +++--- lexicon/providers/gratisdns.py | 10 +++++----- lexicon/providers/henet.py | 4 ++-- lexicon/providers/hetzner.py | 4 ++-- lexicon/providers/hover.py | 8 ++++---- lexicon/providers/infoblox.py | 4 ++-- lexicon/providers/infomaniak.py | 7 +++---- lexicon/providers/internetbs.py | 8 ++++---- lexicon/providers/inwx.py | 7 +++++-- lexicon/providers/joker.py | 6 +++--- lexicon/providers/linode.py | 7 ++++--- lexicon/providers/linode4.py | 6 +++--- lexicon/providers/luadns.py | 4 ++-- lexicon/providers/memset.py | 4 ++-- lexicon/providers/mythicbeasts.py | 12 ++++++------ lexicon/providers/namecheap.py | 4 ++-- lexicon/providers/namesilo.py | 7 +++++-- lexicon/providers/netcup.py | 4 ++-- lexicon/providers/nfsn.py | 7 +++++-- lexicon/providers/njalla.py | 9 ++++++--- lexicon/providers/nsone.py | 4 ++-- lexicon/providers/onapp.py | 7 +++---- lexicon/providers/ovh.py | 6 +++--- lexicon/providers/plesk.py | 4 ++-- lexicon/providers/pointhq.py | 4 ++-- lexicon/providers/rackspace.py | 6 +++--- lexicon/providers/rage4.py | 4 ++-- lexicon/providers/route53.py | 4 ++-- lexicon/providers/safedns.py | 4 ++-- lexicon/providers/sakuracloud.py | 4 ++-- lexicon/providers/softlayer.py | 6 +++--- lexicon/providers/transip.py | 11 +++++------ lexicon/providers/vultr.py | 4 ++-- lexicon/providers/yandex.py | 4 ++-- lexicon/providers/zeit.py | 4 ++-- lexicon/providers/zilore.py | 4 ++-- lexicon/providers/zonomi.py | 4 ++-- 59 files changed, 183 insertions(+), 180 deletions(-) diff --git a/lexicon/providers/aliyun.py b/lexicon/providers/aliyun.py index 3b44cf134..88e22b0d5 100644 --- a/lexicon/providers/aliyun.py +++ b/lexicon/providers/aliyun.py @@ -11,7 +11,7 @@ import requests from six.moves import urllib -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -42,7 +42,7 @@ def _authenticate(self): response = self._request_aliyun("DescribeDomainInfo") if "DomainId" not in response: - raise ValueError(f"failed to fetch basic domain info for {self.domain}") + raise AuthenticationError(f"failed to fetch basic domain info for {self.domain}") self.domain_id = response["DomainId"] diff --git a/lexicon/providers/aurora.py b/lexicon/providers/aurora.py index df0b61552..4d2ffd69a 100644 --- a/lexicon/providers/aurora.py +++ b/lexicon/providers/aurora.py @@ -8,7 +8,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -32,17 +32,14 @@ def __init__(self, config): self.api_endpoint = "https://api.auroradns.eu" def _authenticate(self): - zone = None payload = self._get("/zones") for item in payload: if item["name"] == self.domain: - zone = item - - if not zone: - raise Exception("No domain found") - - self.domain_id = zone["id"] + self.domain_id = item["id"] + break + else: + raise AuthenticationError("No domain found") # Create record. If record already exists with the same content, do nothing' def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/azure.py b/lexicon/providers/azure.py index 44bb6c07d..71cb9a391 100644 --- a/lexicon/providers/azure.py +++ b/lexicon/providers/azure.py @@ -16,7 +16,7 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -279,7 +279,7 @@ def _authenticate(self): ] if not our_data: - raise Exception( + raise AuthenticationError( "Resource group `{0}` in subscription `{1}` " "does not contain the DNS zone `{2}`".format( resource_group, subscription_id, self.domain diff --git a/lexicon/providers/base.py b/lexicon/providers/base.py index 1178b2659..f8c0c3dbc 100644 --- a/lexicon/providers/base.py +++ b/lexicon/providers/base.py @@ -5,6 +5,10 @@ from lexicon.config import ConfigResolver, legacy_config_resolver +class AuthenticationError(Exception): + pass + + class Provider(ABC): """ This is the base class for all lexicon Providers. @@ -67,7 +71,7 @@ def authenticate(self) -> None: Authenticate against provider, Make any requests required to get the domain's id for this provider, so it can be used in subsequent calls. - Should throw an error if authentication fails for any reason, + Should throw AuthenticationError or requests.HTTPError if authentication fails for any reason, of if the domain does not exist. """ self._authenticate() diff --git a/lexicon/providers/cloudflare.py b/lexicon/providers/cloudflare.py index b05ac3fa2..00620d2f1 100644 --- a/lexicon/providers/cloudflare.py +++ b/lexicon/providers/cloudflare.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -50,16 +50,16 @@ def _authenticate(self): payload = self._get("/zones", {"name": self.domain, "status": "active"}) if not payload["result"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") if len(payload["result"]) > 1: - raise Exception("Too many domains found. This should not happen") + raise AuthenticationError("Too many domains found. This should not happen") self.domain_id = payload["result"][0]["id"] else: payload = self._get(f"/zones/{zone_id}") if not payload["result"]: - raise Exception(f"No domain found for Zone ID {zone_id}") + raise AuthenticationError(f"No domain found for Zone ID {zone_id}") self.domain_id = zone_id diff --git a/lexicon/providers/cloudxns.py b/lexicon/providers/cloudxns.py index 74d1338bd..7998d1e27 100644 --- a/lexicon/providers/cloudxns.py +++ b/lexicon/providers/cloudxns.py @@ -8,7 +8,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -36,9 +36,8 @@ def _authenticate(self): if record["domain"] == self.domain + ".": self.domain_id = record["id"] break - - if self.domain_id is None: - raise Exception("No domain found") + else: + raise AuthenticationError("No domain found") # Create record. If record already exists with the same content, do nothing' def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/conoha.py b/lexicon/providers/conoha.py index 8695588b8..613eb3b19 100644 --- a/lexicon/providers/conoha.py +++ b/lexicon/providers/conoha.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -85,9 +85,9 @@ def _authenticate(self): payload = self._get("/domains", {"name": self._fqdn_name(self.domain)}) if not payload["domains"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") if len(payload["domains"]) > 1: - raise Exception("Too many domains found. This should not happen") + raise AuthenticationError("Too many domains found. This should not happen") self.domain_id = payload["domains"][0]["id"] diff --git a/lexicon/providers/constellix.py b/lexicon/providers/constellix.py index b75e13492..4a463716f 100644 --- a/lexicon/providers/constellix.py +++ b/lexicon/providers/constellix.py @@ -24,7 +24,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -61,10 +61,9 @@ def _authenticate(self): if domain["name"] == self.domain: self.domain_id = domain["id"] self.domain_details = domain - continue - - if not self.domain_id: - raise Exception("No domain found") + break + else: + raise AuthenticationError("No domain found") # Create record. If record already exists with the same content, do nothing' diff --git a/lexicon/providers/dinahosting.py b/lexicon/providers/dinahosting.py index 15ede08eb..61c323a7f 100644 --- a/lexicon/providers/dinahosting.py +++ b/lexicon/providers/dinahosting.py @@ -5,7 +5,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -61,14 +61,13 @@ def _authenticate(self): payload = self._post("", data) if not payload["data"]: - raise Exception("No domain found") - domain_found = False + raise AuthenticationError("No domain found") + for data in payload["data"]: if data["domain"] == self.domain: - domain_found = True break - if not domain_found: - raise Exception("Requested domain is not among the owned domains") + else: + raise AuthenticationError("Requested domain is not among the owned domains") self.domain_id = self.domain diff --git a/lexicon/providers/directadmin.py b/lexicon/providers/directadmin.py index 6d1726645..5de67da0c 100644 --- a/lexicon/providers/directadmin.py +++ b/lexicon/providers/directadmin.py @@ -6,7 +6,7 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -46,16 +46,14 @@ def _authenticate(self): except requests.exceptions.HTTPError as err: # A 401 error will be returned in case of incorrect or missing # credentials - cause = err.response.json()["error"] - raise Exception(cause) + raise err # The response is a URL encoded array containing all available domains domains = [domain.split("=").pop() for domain in response.split("&")] - try: self.domain_id = domains.index(self.domain) - except BaseException: - raise Exception(f"Domain {self.domain} not found") + except ValueError: + raise AuthenticationError(f"Domain {self.domain} not found") def _create_record(self, rtype, name, content): # Refuse to create duplicate records diff --git a/lexicon/providers/dnsimple.py b/lexicon/providers/dnsimple.py index ac63b5018..d78648a70 100644 --- a/lexicon/providers/dnsimple.py +++ b/lexicon/providers/dnsimple.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -42,7 +42,7 @@ def _authenticate(self): payload = self._get("/accounts") if not payload[0]["id"]: - raise Exception("No account id found") + raise AuthenticationError("No account id found") for account in payload: if account["plan_identifier"] is None: @@ -60,9 +60,9 @@ def _authenticate(self): if dompayload and dompayload[0]["id"]: self.account_id = account["id"] self.domain_id = dompayload[0]["id"] - - if not self.account_id: - raise Exception(f"No domain found like {self.domain}") + break + else: + raise AuthenticationError(f"No domain found like {self.domain}") # Create record. If record already exists with the same content, do nothing diff --git a/lexicon/providers/dnsmadeeasy.py b/lexicon/providers/dnsmadeeasy.py index 8c825c64b..b47c93ad0 100644 --- a/lexicon/providers/dnsmadeeasy.py +++ b/lexicon/providers/dnsmadeeasy.py @@ -10,7 +10,7 @@ from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry # type: ignore -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -70,7 +70,7 @@ def _authenticate(self): raise if not payload or not payload["id"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = payload["id"] diff --git a/lexicon/providers/dnspark.py b/lexicon/providers/dnspark.py index 06f8bf2d7..9a4452c17 100644 --- a/lexicon/providers/dnspark.py +++ b/lexicon/providers/dnspark.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -30,7 +30,7 @@ def _authenticate(self): payload = self._get(f"/dns/{self.domain}") if not payload["additional"]["domain_id"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = payload["additional"]["domain_id"] diff --git a/lexicon/providers/dnspod.py b/lexicon/providers/dnspod.py index c4d294bbd..e38f4e812 100644 --- a/lexicon/providers/dnspod.py +++ b/lexicon/providers/dnspod.py @@ -3,7 +3,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -29,7 +29,7 @@ def _authenticate(self): payload = self._post("/Domain.Info", {"domain": self.domain}) if payload["status"]["code"] != "1": - raise Exception(payload["status"]["message"]) + raise AuthenticationError(payload["status"]["message"]) self.domain_id = payload["domain"]["id"] diff --git a/lexicon/providers/dreamhost.py b/lexicon/providers/dreamhost.py index c247bab8a..6ca9c33d8 100644 --- a/lexicon/providers/dreamhost.py +++ b/lexicon/providers/dreamhost.py @@ -6,7 +6,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -102,13 +102,13 @@ def _authenticate(self): payload = self._get("domain-list_domains") data = payload.get("data", None) if data is None: - raise Exception("Domain not found") + raise AuthenticationError("Domain not found") for domain in data: if domain.get("domain", "") == self.domain: self.domain_id = self.domain if self.domain_id is None: - raise Exception("Domain not found") + raise AuthenticationError("Domain not found") def _create_record(self, rtype, name, content): name = self._full_name(name) diff --git a/lexicon/providers/dynu.py b/lexicon/providers/dynu.py index 1085c869c..e29a6d01e 100644 --- a/lexicon/providers/dynu.py +++ b/lexicon/providers/dynu.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -33,8 +33,8 @@ def _authenticate(self): if domain["name"].lower() == self.domain.lower(): self.domain_id = domain["id"] break - if not self.domain_id: - raise Exception("No matching domain found") + else: + raise AuthenticationError("No matching domain found") # Create record. If record already exists with the same content, do nothing. def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/easydns.py b/lexicon/providers/easydns.py index 5e9d56f53..81e92b15c 100644 --- a/lexicon/providers/easydns.py +++ b/lexicon/providers/easydns.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -34,7 +34,7 @@ def _authenticate(self): payload = self._get(f"/domain/{self.domain}") if payload["data"]["exists"] == "N": - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = payload["data"]["id"] diff --git a/lexicon/providers/euserv.py b/lexicon/providers/euserv.py index 92cf94dfa..ebccaeb02 100644 --- a/lexicon/providers/euserv.py +++ b/lexicon/providers/euserv.py @@ -10,7 +10,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -51,7 +51,7 @@ def _authenticate(self): self._get_provider_option("auth_username") and self._get_provider_option("auth_password") ): - raise Exception( + raise ValueError( "username and password must be specified, add --help for details" ) @@ -81,9 +81,8 @@ def _authenticate(self): if order_description[1] == self.domain: self.order_id = order["ord_no"]["value"] break - - if self.order_id is None: - raise Exception("Order for domain not found") + else: + raise AuthenticationError("Order for domain not found") # Select the order for the given domain so we can use the DNS actions LOGGER.info("Choosing order %s", self.order_id) @@ -97,9 +96,8 @@ def _authenticate(self): if domain["dom_domain"]["value"] == self.domain: self.domain_id = domain["dom_id"]["value"] break - - if self.domain_id is None: - raise Exception("Domain not found in DNS records") + else: + raise AuthenticationError("Domain not found in DNS records") def _create_record(self, rtype, name, content): records = self._list_records(rtype, name, content) diff --git a/lexicon/providers/gandi.py b/lexicon/providers/gandi.py index 1065b18fa..481d6bf90 100644 --- a/lexicon/providers/gandi.py +++ b/lexicon/providers/gandi.py @@ -31,7 +31,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError try: import xmlrpclib # type: ignore @@ -313,7 +313,7 @@ def authenticate(self): self._zone_id = payload["zone_id"] return payload["id"] except xmlrpclib.Fault as err: - raise Exception(f"Failed to authenticate: '{err}'") + raise AuthenticationError(f"Failed to authenticate: '{err}'") # Create record. If record already exists with the same content, do nothing. def create_record(self, rtype, name, content, ttl): diff --git a/lexicon/providers/gehirn.py b/lexicon/providers/gehirn.py index a6c6ef6a2..f83bbbef7 100644 --- a/lexicon/providers/gehirn.py +++ b/lexicon/providers/gehirn.py @@ -7,7 +7,7 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -61,7 +61,7 @@ def _authenticate(self): domains = [item for item in payload if item["name"] == self.domain] if not domains: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = domains[0]["id"] self.version_id = domains[0]["current_version_id"] diff --git a/lexicon/providers/glesys.py b/lexicon/providers/glesys.py index d0138ed78..4ceda6fb8 100644 --- a/lexicon/providers/glesys.py +++ b/lexicon/providers/glesys.py @@ -3,7 +3,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError NAMESERVER_DOMAINS = ["glesys.com"] @@ -31,9 +31,8 @@ def _authenticate(self): # Since domain_id cannot be None, use domain name as id instead. self.domain_id = record["domainname"] break - - if self.domain_id is None: - raise Exception("No domain found") + else: + raise AuthenticationError("No domain found") # Create record. If record already exists with the same content, do nothing. def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/googleclouddns.py b/lexicon/providers/googleclouddns.py index 56e0b6932..dbb53c067 100644 --- a/lexicon/providers/googleclouddns.py +++ b/lexicon/providers/googleclouddns.py @@ -30,7 +30,7 @@ from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import padding -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -181,7 +181,7 @@ def _authenticate(self): post_result = auth_request.json() if not post_result["access_token"]: - raise Exception( + raise AuthenticationError( "Error, could not grant RW access on the " f"Google Cloud DNS API for user: {self._get_provider_option('auth_email')}" ) @@ -190,7 +190,7 @@ def _authenticate(self): targeted_managed_zone_ids = self._get_managed_zone_ids([]) if not targeted_managed_zone_ids: - raise Exception( + raise AuthenticationError( f"Error, domain {self.domain} is not registered for this project" ) diff --git a/lexicon/providers/gransy.py b/lexicon/providers/gransy.py index 8d94327dd..fcfc0c062 100644 --- a/lexicon/providers/gransy.py +++ b/lexicon/providers/gransy.py @@ -9,7 +9,7 @@ except BaseException: pass -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -70,9 +70,9 @@ def _authenticate(self): if any((domain["name"] == self.domain for domain in domains)): self.domain_id = self.domain else: - raise Exception(f"Unknown domain {self.domain}") + raise AuthenticationError(f"Unknown domain {self.domain}") else: - raise Exception("No SSID provided by server") + raise AuthenticationError("No SSID provided by server") # Create record. If record already exists with the same content, do nothing. def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/gratisdns.py b/lexicon/providers/gratisdns.py index c316989d0..c07e1dc57 100644 --- a/lexicon/providers/gratisdns.py +++ b/lexicon/providers/gratisdns.py @@ -4,7 +4,7 @@ import requests from bs4 import BeautifulSoup # type: ignore -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -44,7 +44,7 @@ def _authenticate(self): response.raise_for_status() if "ORGID" not in response.cookies: - raise Exception("Unexpected auth response") + raise AuthenticationError("Unexpected auth response") self.cookies["ORGID"] = response.cookies["ORGID"] # Make sure domain exists @@ -54,9 +54,9 @@ def _authenticate(self): if domain == self.domain: # Domain name is the ID self.domain_id = domain - - if self.domain_id is None: - raise Exception(f"Domain {self.domain} not found") + break + else: + raise AuthenticationError(f"Domain {self.domain} not found") def _list_domains(self): query_params = {"action": "dns_primarydns"} diff --git a/lexicon/providers/henet.py b/lexicon/providers/henet.py index 432df907a..a2ba1a110 100644 --- a/lexicon/providers/henet.py +++ b/lexicon/providers/henet.py @@ -5,7 +5,7 @@ from bs4 import BeautifulSoup # type: ignore from requests import Session -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -66,7 +66,7 @@ def _authenticate(self): # If the tag couldn't be found, error, otherwise, return the value of the tag if zone_img is None: LOGGER.warning("Domain %s not found in account", self.domain) - raise AssertionError(f"Domain {self.domain} not found in account") + raise AuthenticationError(f"Domain {self.domain} not found in account") self.domain_id = zone_img["value"] LOGGER.debug("HENET domain ID: %s", self.domain_id) diff --git a/lexicon/providers/hetzner.py b/lexicon/providers/hetzner.py index a4477e525..af4592916 100644 --- a/lexicon/providers/hetzner.py +++ b/lexicon/providers/hetzner.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) NAMESERVER_DOMAINS = ["ns.hetzner.com"] @@ -173,7 +173,7 @@ def _get_zone_by_domain(self, domain): for zone in zones: if zone["name"] == domain: return zone - raise Exception(f"No zone was found in account matching {domain}") + raise AuthenticationError(f"No zone was found in account matching {domain}") def _get_record_name(self, domain, record_name): """ diff --git a/lexicon/providers/hover.py b/lexicon/providers/hover.py index 69dd71e1d..a5bd5ec5a 100644 --- a/lexicon/providers/hover.py +++ b/lexicon/providers/hover.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -55,9 +55,9 @@ def _authenticate(self): for domain in domains: if domain["name"] == self.domain: self.domain_id = domain["id"] - - if self.domain_id is None: - raise Exception(f"Domain {self.domain} not found") + break + else: + raise AuthenticationError(f"Domain {self.domain} not found") def _list_domains(self): response = self._get("/domains") diff --git a/lexicon/providers/infoblox.py b/lexicon/providers/infoblox.py index 24a6d828c..a2cb4652c 100644 --- a/lexicon/providers/infoblox.py +++ b/lexicon/providers/infoblox.py @@ -19,7 +19,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -96,7 +96,7 @@ def _authenticate(self): self.domain_id = domains[0]["_ref"] except IndexError: LOGGER.error("Domain %s not found in view", self.domain) - raise Exception(f"Domain {self.domain} not found in view") + raise AuthenticationError(f"Domain {self.domain} not found in view") # Create record. If record already exists with the same content, do nothing' def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/infomaniak.py b/lexicon/providers/infomaniak.py index 8c3950e90..6c7cba2f9 100644 --- a/lexicon/providers/infomaniak.py +++ b/lexicon/providers/infomaniak.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -49,9 +49,8 @@ def _authenticate(self): if domain["customer_name"] == self.domain: self.domain_id = domain["id"] break - - if not self.domain_id: - raise Exception(f"Domain {self.domain} not found") + else: + raise AuthenticationError(f"Domain {self.domain} not found") def _create_record(self, rtype, name, content): ttl = self._get_lexicon_option("ttl") diff --git a/lexicon/providers/internetbs.py b/lexicon/providers/internetbs.py index 279af5750..b80c0a72a 100644 --- a/lexicon/providers/internetbs.py +++ b/lexicon/providers/internetbs.py @@ -18,7 +18,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -46,11 +46,11 @@ def _authenticate(self): LOGGER.debug("authenticate debug: %s", payload) if not payload["status"]: - raise Exception("Internal error. This should not happen") + raise AuthenticationError("Internal error. This should not happen") if payload["status"] != "SUCCESS": - raise Exception(f"Api error: {payload['message']}") + raise AuthenticationError(f"Api error: {payload['message']}") if self.domain not in payload["domain"]: - raise Exception("Domain not found") + raise AuthenticationError("Domain not found") self.domain_id = self.domain # Create record. If record already exists with the same content, do nothing' diff --git a/lexicon/providers/inwx.py b/lexicon/providers/inwx.py index 50ccc7eb9..ba168068e 100644 --- a/lexicon/providers/inwx.py +++ b/lexicon/providers/inwx.py @@ -1,7 +1,7 @@ """Module provider for INWX""" import logging -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError try: import xmlrpclib # type: ignore @@ -76,7 +76,10 @@ def _authenticate(self): opts = {"domain": self._domain} opts.update(self._auth) response = self._api.domain.info(opts) - self._validate_response(response=response, message="Failed to authenticate") + try: + self._validate_response(response=response, message="Failed to authenticate") + except Exception as e: + raise AuthenticationError(str(e)) # set to fake id to pass tests, inwx doesn't work on domain id but # uses domain names for identification diff --git a/lexicon/providers/joker.py b/lexicon/providers/joker.py index beef85cb8..1c64010ad 100644 --- a/lexicon/providers/joker.py +++ b/lexicon/providers/joker.py @@ -19,7 +19,7 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -71,7 +71,7 @@ def _authenticate(self): ) if not response.data: - raise ValueError( + raise AuthenticationError( f"Domain {self.domain} is not registered with this account." ) @@ -79,7 +79,7 @@ def _authenticate(self): items = data.split(" ") if items[2] not in ["production", "lock"]: - raise ValueError(f"Current status for domain {self.domain} is: {items[2]}") + raise AuthenticationError(f"Current status for domain {self.domain} is: {items[2]}") self.domain_id = self.domain diff --git a/lexicon/providers/linode.py b/lexicon/providers/linode.py index f85ee1694..2e741eec4 100644 --- a/lexicon/providers/linode.py +++ b/lexicon/providers/linode.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -30,8 +30,9 @@ def _authenticate(self): for domain in payload["DATA"]: if domain["DOMAIN"].lower() == self.domain.lower(): self.domain_id = domain["DOMAINID"] - if self.domain_id is None: - raise Exception("Domain not found") + break + else: + raise AuthenticationError("Domain not found") def _create_record(self, rtype, name, content): if not self._list_records(rtype, name, content): diff --git a/lexicon/providers/linode4.py b/lexicon/providers/linode4.py index 4556b00b3..f23ce4f42 100644 --- a/lexicon/providers/linode4.py +++ b/lexicon/providers/linode4.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -31,8 +31,8 @@ def _authenticate(self): ) if payload["data"]: self.domain_id = payload["data"][0]["id"] - if self.domain_id is None: - raise Exception("Domain not found") + else: + raise AuthenticationError("Domain not found") def _create_record(self, rtype, name, content): if not self._list_records(rtype, name, content): diff --git a/lexicon/providers/luadns.py b/lexicon/providers/luadns.py index 674e9b892..6e409cbce 100644 --- a/lexicon/providers/luadns.py +++ b/lexicon/providers/luadns.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -35,7 +35,7 @@ def _authenticate(self): ) if not domain_info: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = domain_info["id"] diff --git a/lexicon/providers/memset.py b/lexicon/providers/memset.py index 31c7ba77b..50a43f72c 100644 --- a/lexicon/providers/memset.py +++ b/lexicon/providers/memset.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -27,7 +27,7 @@ def __init__(self, config): def _authenticate(self): payload = self._get("/dns.zone_domain_info", {"domain": self.domain}) if not payload["zone_id"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = payload["zone_id"] # Create record. If record already exists with the same content, do nothing' diff --git a/lexicon/providers/mythicbeasts.py b/lexicon/providers/mythicbeasts.py index 2f373c289..325e14fb1 100644 --- a/lexicon/providers/mythicbeasts.py +++ b/lexicon/providers/mythicbeasts.py @@ -9,7 +9,7 @@ from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry # type: ignore -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -64,7 +64,7 @@ def _authenticate(self): post_result = auth_request.json() if not post_result["access_token"]: - raise Exception( + raise AuthenticationError( "Error, could not get access token " f"for Mythic Beasts API for user: {self._get_provider_option('auth_username')}" ) @@ -77,16 +77,16 @@ def _authenticate(self): if self.domain is None: if not payload["zones"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") if len(payload["zones"]) > 1: - raise Exception("Too many domains found. This should not happen") + raise AuthenticationError("Too many domains found. This should not happen") else: self.domain = payload["zones"][0] else: if not payload["zones"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") if self.domain not in payload["zones"]: - raise Exception("Requested domain not found") + raise AuthenticationError("Requested domain not found") self.domain_id = self.domain diff --git a/lexicon/providers/namecheap.py b/lexicon/providers/namecheap.py index 0870910d9..2975a8dbb 100644 --- a/lexicon/providers/namecheap.py +++ b/lexicon/providers/namecheap.py @@ -6,7 +6,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -117,7 +117,7 @@ def _authenticate(self): # OR if the user is not permissioned to manage this domain # OR the API request came from a not whitelisted IP # we should print the error, so people know how to correct it. - raise Exception(f"Authentication failed: `{str(err)}`") + raise AuthenticationError(f"Authentication failed: `{str(err)}`") xpath = ".//{%(ns)s}CommandResponse/{%(ns)s}DomainGetInfoResult" % { "ns": _NAMESPACE diff --git a/lexicon/providers/namesilo.py b/lexicon/providers/namesilo.py index 90b9b2c95..e6410d6b7 100644 --- a/lexicon/providers/namesilo.py +++ b/lexicon/providers/namesilo.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -27,7 +27,10 @@ def __init__(self, config): ) def _authenticate(self): - self._get("/getDomainInfo", {"domain": self.domain}) + try: + self._get("/getDomainInfo", {"domain": self.domain}) + except Exception as e: + raise AuthenticationError(str(e)) self.domain_id = self.domain # Create record. If record already exists with the same content, do nothing' diff --git a/lexicon/providers/netcup.py b/lexicon/providers/netcup.py index 806077475..91630fd63 100644 --- a/lexicon/providers/netcup.py +++ b/lexicon/providers/netcup.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -42,7 +42,7 @@ def _authenticate(self): login_info = self._apicall("login") self.api_session_id = login_info["apisessionid"] if not self.api_session_id: - raise Exception("Login failed") + raise AuthenticationError("Login failed") # query ttl and verify access to self.domain: zone_info = self._apicall("infoDnsZone", domainname=self.domain) self.zone_ttl = zone_info["ttl"] diff --git a/lexicon/providers/nfsn.py b/lexicon/providers/nfsn.py index 22fecc0f4..c7f243587 100644 --- a/lexicon/providers/nfsn.py +++ b/lexicon/providers/nfsn.py @@ -9,7 +9,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -37,7 +37,10 @@ def __init__(self, config): self.shortname = None def _authenticate(self): - self._post(f"/dns/{self.domain}/listRRs") + try: + self._post(f"/dns/{self.domain}/listRRs") + except Exception as e: + raise AuthenticationError(e) self.domain_id = self.domain # Create record. If record already exists with the same content, do nothing' diff --git a/lexicon/providers/njalla.py b/lexicon/providers/njalla.py index 890f37317..733112c8b 100644 --- a/lexicon/providers/njalla.py +++ b/lexicon/providers/njalla.py @@ -3,7 +3,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -25,10 +25,13 @@ def __init__(self, config): def _authenticate(self): params = {"domain": self.domain} - result = self._api_call("get-domain", params) + try: + result = self._api_call("get-domain", params) + except Exception as e: + raise AuthenticationError(str(e)) if result["name"] != self.domain: - raise Exception("Domain not found") + raise AuthenticationError("Domain not found") self.domain_id = self.domain diff --git a/lexicon/providers/nsone.py b/lexicon/providers/nsone.py index 73da30cc8..15b190fa7 100644 --- a/lexicon/providers/nsone.py +++ b/lexicon/providers/nsone.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -29,7 +29,7 @@ def _authenticate(self): payload = self._get(f"/zones/{self.domain}") if not payload["id"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = self.domain diff --git a/lexicon/providers/onapp.py b/lexicon/providers/onapp.py index fbafaf2ef..b1ab43c9a 100644 --- a/lexicon/providers/onapp.py +++ b/lexicon/providers/onapp.py @@ -6,7 +6,7 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -53,9 +53,8 @@ def _authenticate(self): if zone["dns_zone"]["name"] == domain: self.domain_id = zone["dns_zone"]["id"] break - - if self.domain_id is None: - raise Exception(f"Could not find {domain} in OnApp DNS Zones") + else: + raise AuthenticationError(f"Could not find {domain} in OnApp DNS Zones") def _create_record(self, rtype, name, content): data = { diff --git a/lexicon/providers/ovh.py b/lexicon/providers/ovh.py index 1405285d0..3707e0a7f 100644 --- a/lexicon/providers/ovh.py +++ b/lexicon/providers/ovh.py @@ -6,7 +6,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -83,11 +83,11 @@ def _authenticate(self): domains = self._get("/domain/zone/") if domain not in domains: - raise Exception(f"Domain {domain} not found") + raise AuthenticationError(f"Domain {domain} not found") status = self._get(f"/domain/zone/{domain}/status") if not status["isDeployed"]: - raise Exception(f"Zone {domain} is not deployed") + raise AuthenticationError(f"Zone {domain} is not deployed") self.domain_id = domain diff --git a/lexicon/providers/plesk.py b/lexicon/providers/plesk.py index 8211592c2..64c332171 100644 --- a/lexicon/providers/plesk.py +++ b/lexicon/providers/plesk.py @@ -13,7 +13,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -117,7 +117,7 @@ def _authenticate(self): self.domain_id = self.__find_site() if self.domain_id is None: - raise Exception("Domain not found") + raise AuthenticationError("Domain not found") def _create_record(self, rtype, name, content): return self.__create_entry(rtype, name, content, None) diff --git a/lexicon/providers/pointhq.py b/lexicon/providers/pointhq.py index 5421ef022..98debeeee 100644 --- a/lexicon/providers/pointhq.py +++ b/lexicon/providers/pointhq.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -32,7 +32,7 @@ def _authenticate(self): payload = self._get(f"/zones/{self.domain}") if not payload["zone"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = payload["zone"]["id"] diff --git a/lexicon/providers/rackspace.py b/lexicon/providers/rackspace.py index 127e88b1e..e2daf37ec 100644 --- a/lexicon/providers/rackspace.py +++ b/lexicon/providers/rackspace.py @@ -5,7 +5,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -90,9 +90,9 @@ def _authenticate(self): payload = self._get("/domains", {"name": self.domain}) if not payload["domains"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") if len(payload["domains"]) > 1: - raise Exception("Too many domains found. This should not happen") + raise AuthenticationError("Too many domains found. This should not happen") self.domain_id = payload["domains"][0]["id"] diff --git a/lexicon/providers/rage4.py b/lexicon/providers/rage4.py index d7ec0a629..707342b58 100644 --- a/lexicon/providers/rage4.py +++ b/lexicon/providers/rage4.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -32,7 +32,7 @@ def _authenticate(self): payload = self._get("/getdomainbyname/", {"name": self.domain}) if not payload["id"]: - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = payload["id"] diff --git a/lexicon/providers/route53.py b/lexicon/providers/route53.py index 9ddee3820..7142523c3 100644 --- a/lexicon/providers/route53.py +++ b/lexicon/providers/route53.py @@ -3,7 +3,7 @@ import logging import re -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError try: import boto3 # type: ignore @@ -151,7 +151,7 @@ def _authenticate(self): hosted_zone = next(hz for hz in hosted_zones if self.filter_zone(hz)) self.domain_id = hosted_zone.get("Id") except StopIteration: - raise Exception("No domain found") + raise AuthenticationError("No domain found") def _change_record_sets(self, action, rtype, name, content): ttl = self._get_lexicon_option("ttl") diff --git a/lexicon/providers/safedns.py b/lexicon/providers/safedns.py index d65bcf7d5..8cf0d8907 100644 --- a/lexicon/providers/safedns.py +++ b/lexicon/providers/safedns.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -36,7 +36,7 @@ def _authenticate(self): self.domain_id = self.domain except requests.exceptions.HTTPError as err: if err.response.status_code == 404: - raise Exception("No domain found") + raise AuthenticationError("No domain found") raise err # List all records. Return an empty list if no records found. diff --git a/lexicon/providers/sakuracloud.py b/lexicon/providers/sakuracloud.py index 6cd5d3896..66d5c0e2c 100644 --- a/lexicon/providers/sakuracloud.py +++ b/lexicon/providers/sakuracloud.py @@ -5,7 +5,7 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -40,7 +40,7 @@ def _authenticate(self): self.domain_id = item["ID"] return - raise Exception("No domain found") + raise AuthenticationError("No domain found") # Create record. If record already exists with the same content, do nothing' def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/softlayer.py b/lexicon/providers/softlayer.py index e57b73e08..258f1a16c 100644 --- a/lexicon/providers/softlayer.py +++ b/lexicon/providers/softlayer.py @@ -1,7 +1,7 @@ """Module provider for Softlayer""" import logging -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError try: import SoftLayer # type: ignore @@ -50,9 +50,9 @@ def _authenticate(self): payload = self.sl_dns.resolve_ids(domain) if not payload: - raise Exception("No domain found") + raise AuthenticationError("No domain found") if len(payload) > 1: - raise Exception("Too many domains found. This should not happen") + raise AuthenticationError("Too many domains found. This should not happen") LOGGER.debug("domain id: %s", payload[0]) self.domain_id = payload[0] diff --git a/lexicon/providers/transip.py b/lexicon/providers/transip.py index b19ce8c3c..142a403e8 100644 --- a/lexicon/providers/transip.py +++ b/lexicon/providers/transip.py @@ -2,7 +2,7 @@ import logging from typing import List -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError # Support various versions of Transip Python API try: @@ -64,14 +64,13 @@ def __init__(self, config): def _authenticate(self): # This request will fail when the domain does not exist, # allowing us to check for existence - domain = self.domain try: - self.client.get_info(domain) + self.client.get_info(self.domain) except BaseException: - raise Exception( - f"Could not retrieve information about {domain}, is this domain yours?" + raise AuthenticationError( + f"Could not retrieve information about {self.domain}, is this domain yours?" ) - self.domain_id = domain + self.domain_id = self.domain # Create record. If record already exists with the same content, do nothing' def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/vultr.py b/lexicon/providers/vultr.py index 80f2d3f22..cd692972e 100644 --- a/lexicon/providers/vultr.py +++ b/lexicon/providers/vultr.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -41,7 +41,7 @@ def _authenticate(self): self.domain_id = self.domain return - raise Exception("Domain not found") + raise AuthenticationError("Domain not found") # Create record. If record already exists with the same content, do nothing def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/yandex.py b/lexicon/providers/yandex.py index 1adffb63b..33226b731 100644 --- a/lexicon/providers/yandex.py +++ b/lexicon/providers/yandex.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError __author__ = "Aliaksandr Kharkevich" __license__ = "MIT" @@ -34,7 +34,7 @@ def __init__(self, config): def _authenticate(self): payload = self._get(f"/list?domain={self.domain}") if payload["success"] != "ok": - raise Exception("No domain found") + raise AuthenticationError("No domain found") self.domain_id = self.domain def _create_record(self, rtype, name, content): diff --git a/lexicon/providers/zeit.py b/lexicon/providers/zeit.py index b683d95cc..19552e002 100644 --- a/lexicon/providers/zeit.py +++ b/lexicon/providers/zeit.py @@ -4,7 +4,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -41,7 +41,7 @@ def _authenticate(self): result = self._get(f"/{self.domain}") if not result["uid"]: - raise Exception(f"Error, domain {self.domain} not found") + raise AuthenticationError(f"Error, domain {self.domain} not found") self.domain_id = result["uid"] diff --git a/lexicon/providers/zilore.py b/lexicon/providers/zilore.py index b703f5377..e0741faac 100644 --- a/lexicon/providers/zilore.py +++ b/lexicon/providers/zilore.py @@ -3,7 +3,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -43,7 +43,7 @@ def _authenticate(self): ] if not target_domain: - raise Exception(f"Domain {self.domain} is not available on this account") + raise AuthenticationError(f"Domain {self.domain} is not available on this account") self.domain_id = target_domain[0]["domain_id"] diff --git a/lexicon/providers/zonomi.py b/lexicon/providers/zonomi.py index 446608186..8d0fa23b6 100644 --- a/lexicon/providers/zonomi.py +++ b/lexicon/providers/zonomi.py @@ -22,7 +22,7 @@ import requests -from lexicon.providers.base import Provider as BaseProvider +from lexicon.providers.base import Provider as BaseProvider, AuthenticationError LOGGER = logging.getLogger(__name__) @@ -68,7 +68,7 @@ def _authenticate(self): ) if payload.find("is_ok").text != "OK:": - raise Exception(f"Error with api {payload.find('is_ok').text}") + raise AuthenticationError(f"Error with api {payload.find('is_ok').text}") self.domain_id = self.domain From 595cc0974d890dc560704d9c753ea38a1e3bc78b Mon Sep 17 00:00:00 2001 From: Markus Koetter Date: Mon, 26 Apr 2021 09:36:44 +0200 Subject: [PATCH 2/2] exceptions - juse lexicon.exceptions and inherit from LexiconError --- lexicon/exceptions.py | 14 +++++++++++++- lexicon/providers/aliyun.py | 3 ++- lexicon/providers/aurora.py | 3 ++- lexicon/providers/azure.py | 3 ++- lexicon/providers/base.py | 4 ---- lexicon/providers/cloudflare.py | 3 ++- lexicon/providers/cloudxns.py | 3 ++- lexicon/providers/conoha.py | 3 ++- lexicon/providers/constellix.py | 3 ++- lexicon/providers/dinahosting.py | 3 ++- lexicon/providers/directadmin.py | 3 ++- lexicon/providers/dnsimple.py | 3 ++- lexicon/providers/dnsmadeeasy.py | 3 ++- lexicon/providers/dnspark.py | 3 ++- lexicon/providers/dnspod.py | 3 ++- lexicon/providers/dreamhost.py | 3 ++- lexicon/providers/dynu.py | 3 ++- lexicon/providers/easydns.py | 3 ++- lexicon/providers/euserv.py | 3 ++- lexicon/providers/gandi.py | 3 ++- lexicon/providers/gehirn.py | 3 ++- lexicon/providers/glesys.py | 3 ++- lexicon/providers/googleclouddns.py | 3 ++- lexicon/providers/gransy.py | 3 ++- lexicon/providers/gratisdns.py | 3 ++- lexicon/providers/henet.py | 3 ++- lexicon/providers/hetzner.py | 3 ++- lexicon/providers/hover.py | 3 ++- lexicon/providers/infoblox.py | 3 ++- lexicon/providers/infomaniak.py | 3 ++- lexicon/providers/internetbs.py | 3 ++- lexicon/providers/inwx.py | 3 ++- lexicon/providers/joker.py | 3 ++- lexicon/providers/linode.py | 3 ++- lexicon/providers/linode4.py | 3 ++- lexicon/providers/luadns.py | 3 ++- lexicon/providers/memset.py | 3 ++- lexicon/providers/mythicbeasts.py | 3 ++- lexicon/providers/namecheap.py | 3 ++- lexicon/providers/namesilo.py | 3 ++- lexicon/providers/netcup.py | 3 ++- lexicon/providers/nfsn.py | 3 ++- lexicon/providers/njalla.py | 3 ++- lexicon/providers/nsone.py | 3 ++- lexicon/providers/onapp.py | 3 ++- lexicon/providers/ovh.py | 3 ++- lexicon/providers/plesk.py | 3 ++- lexicon/providers/pointhq.py | 3 ++- lexicon/providers/rackspace.py | 3 ++- lexicon/providers/rage4.py | 3 ++- lexicon/providers/route53.py | 3 ++- lexicon/providers/safedns.py | 3 ++- lexicon/providers/sakuracloud.py | 3 ++- lexicon/providers/softlayer.py | 3 ++- lexicon/providers/transip.py | 3 ++- lexicon/providers/vultr.py | 3 ++- lexicon/providers/yandex.py | 3 ++- lexicon/providers/zeit.py | 3 ++- lexicon/providers/zilore.py | 3 ++- lexicon/providers/zonomi.py | 3 ++- 60 files changed, 129 insertions(+), 63 deletions(-) diff --git a/lexicon/exceptions.py b/lexicon/exceptions.py index ea7e19be7..12cd96d2e 100644 --- a/lexicon/exceptions.py +++ b/lexicon/exceptions.py @@ -1,8 +1,20 @@ """Lexicon exceptions module""" -class ProviderNotAvailableError(Exception): +class LexiconError(Exception): + """ + Base Class for the Lexicon Exception hierarchy + """ + + +class ProviderNotAvailableError(LexiconError): """ Custom exception to raise when a provider is not available, typically because some optional dependencies are missing """ + + +class AuthenticationError(LexiconError): + """ + Authentication to the provider failed, likely username, password or domain mismatch + """ diff --git a/lexicon/providers/aliyun.py b/lexicon/providers/aliyun.py index 88e22b0d5..4430291ae 100644 --- a/lexicon/providers/aliyun.py +++ b/lexicon/providers/aliyun.py @@ -11,7 +11,8 @@ import requests from six.moves import urllib -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/aurora.py b/lexicon/providers/aurora.py index 4d2ffd69a..4d6e8718b 100644 --- a/lexicon/providers/aurora.py +++ b/lexicon/providers/aurora.py @@ -8,7 +8,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/azure.py b/lexicon/providers/azure.py index 71cb9a391..fe7875213 100644 --- a/lexicon/providers/azure.py +++ b/lexicon/providers/azure.py @@ -16,7 +16,8 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/base.py b/lexicon/providers/base.py index f8c0c3dbc..fc1ce4150 100644 --- a/lexicon/providers/base.py +++ b/lexicon/providers/base.py @@ -5,10 +5,6 @@ from lexicon.config import ConfigResolver, legacy_config_resolver -class AuthenticationError(Exception): - pass - - class Provider(ABC): """ This is the base class for all lexicon Providers. diff --git a/lexicon/providers/cloudflare.py b/lexicon/providers/cloudflare.py index 00620d2f1..70c6a1adb 100644 --- a/lexicon/providers/cloudflare.py +++ b/lexicon/providers/cloudflare.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/cloudxns.py b/lexicon/providers/cloudxns.py index 7998d1e27..6137ac02c 100644 --- a/lexicon/providers/cloudxns.py +++ b/lexicon/providers/cloudxns.py @@ -8,7 +8,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/conoha.py b/lexicon/providers/conoha.py index 613eb3b19..b152bb497 100644 --- a/lexicon/providers/conoha.py +++ b/lexicon/providers/conoha.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/constellix.py b/lexicon/providers/constellix.py index 4a463716f..52dbf7e60 100644 --- a/lexicon/providers/constellix.py +++ b/lexicon/providers/constellix.py @@ -24,7 +24,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dinahosting.py b/lexicon/providers/dinahosting.py index 61c323a7f..023b9df9b 100644 --- a/lexicon/providers/dinahosting.py +++ b/lexicon/providers/dinahosting.py @@ -5,7 +5,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/directadmin.py b/lexicon/providers/directadmin.py index 5de67da0c..576b2e7e2 100644 --- a/lexicon/providers/directadmin.py +++ b/lexicon/providers/directadmin.py @@ -6,7 +6,8 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dnsimple.py b/lexicon/providers/dnsimple.py index d78648a70..5676434f5 100644 --- a/lexicon/providers/dnsimple.py +++ b/lexicon/providers/dnsimple.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dnsmadeeasy.py b/lexicon/providers/dnsmadeeasy.py index b47c93ad0..2ae958ba1 100644 --- a/lexicon/providers/dnsmadeeasy.py +++ b/lexicon/providers/dnsmadeeasy.py @@ -10,7 +10,8 @@ from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry # type: ignore -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dnspark.py b/lexicon/providers/dnspark.py index 9a4452c17..3678fc996 100644 --- a/lexicon/providers/dnspark.py +++ b/lexicon/providers/dnspark.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dnspod.py b/lexicon/providers/dnspod.py index e38f4e812..a28451b3c 100644 --- a/lexicon/providers/dnspod.py +++ b/lexicon/providers/dnspod.py @@ -3,7 +3,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dreamhost.py b/lexicon/providers/dreamhost.py index 6ca9c33d8..5c6af0956 100644 --- a/lexicon/providers/dreamhost.py +++ b/lexicon/providers/dreamhost.py @@ -6,7 +6,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/dynu.py b/lexicon/providers/dynu.py index e29a6d01e..f440f5c12 100644 --- a/lexicon/providers/dynu.py +++ b/lexicon/providers/dynu.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/easydns.py b/lexicon/providers/easydns.py index 81e92b15c..a8fa804a5 100644 --- a/lexicon/providers/easydns.py +++ b/lexicon/providers/easydns.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/euserv.py b/lexicon/providers/euserv.py index ebccaeb02..430fc3b47 100644 --- a/lexicon/providers/euserv.py +++ b/lexicon/providers/euserv.py @@ -10,7 +10,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/gandi.py b/lexicon/providers/gandi.py index 481d6bf90..9527edef7 100644 --- a/lexicon/providers/gandi.py +++ b/lexicon/providers/gandi.py @@ -31,7 +31,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError try: import xmlrpclib # type: ignore diff --git a/lexicon/providers/gehirn.py b/lexicon/providers/gehirn.py index f83bbbef7..8f48074c1 100644 --- a/lexicon/providers/gehirn.py +++ b/lexicon/providers/gehirn.py @@ -7,7 +7,8 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/glesys.py b/lexicon/providers/glesys.py index 4ceda6fb8..b07b21bdc 100644 --- a/lexicon/providers/glesys.py +++ b/lexicon/providers/glesys.py @@ -3,7 +3,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError NAMESERVER_DOMAINS = ["glesys.com"] diff --git a/lexicon/providers/googleclouddns.py b/lexicon/providers/googleclouddns.py index dbb53c067..a1f85775f 100644 --- a/lexicon/providers/googleclouddns.py +++ b/lexicon/providers/googleclouddns.py @@ -30,7 +30,8 @@ from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import padding -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/gransy.py b/lexicon/providers/gransy.py index fcfc0c062..a2fc7935a 100644 --- a/lexicon/providers/gransy.py +++ b/lexicon/providers/gransy.py @@ -9,7 +9,8 @@ except BaseException: pass -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/gratisdns.py b/lexicon/providers/gratisdns.py index c07e1dc57..bca9156a6 100644 --- a/lexicon/providers/gratisdns.py +++ b/lexicon/providers/gratisdns.py @@ -4,7 +4,8 @@ import requests from bs4 import BeautifulSoup # type: ignore -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/henet.py b/lexicon/providers/henet.py index a2ba1a110..9c5f9f8b1 100644 --- a/lexicon/providers/henet.py +++ b/lexicon/providers/henet.py @@ -5,7 +5,8 @@ from bs4 import BeautifulSoup # type: ignore from requests import Session -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/hetzner.py b/lexicon/providers/hetzner.py index af4592916..41b19b182 100644 --- a/lexicon/providers/hetzner.py +++ b/lexicon/providers/hetzner.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) NAMESERVER_DOMAINS = ["ns.hetzner.com"] diff --git a/lexicon/providers/hover.py b/lexicon/providers/hover.py index a5bd5ec5a..36992bbb2 100644 --- a/lexicon/providers/hover.py +++ b/lexicon/providers/hover.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/infoblox.py b/lexicon/providers/infoblox.py index a2cb4652c..bf192941c 100644 --- a/lexicon/providers/infoblox.py +++ b/lexicon/providers/infoblox.py @@ -19,7 +19,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/infomaniak.py b/lexicon/providers/infomaniak.py index 6c7cba2f9..5e4b0e140 100644 --- a/lexicon/providers/infomaniak.py +++ b/lexicon/providers/infomaniak.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/internetbs.py b/lexicon/providers/internetbs.py index b80c0a72a..f33e4dfb9 100644 --- a/lexicon/providers/internetbs.py +++ b/lexicon/providers/internetbs.py @@ -18,7 +18,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/inwx.py b/lexicon/providers/inwx.py index ba168068e..2ad610930 100644 --- a/lexicon/providers/inwx.py +++ b/lexicon/providers/inwx.py @@ -1,7 +1,8 @@ """Module provider for INWX""" import logging -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError try: import xmlrpclib # type: ignore diff --git a/lexicon/providers/joker.py b/lexicon/providers/joker.py index 1c64010ad..ed68016c1 100644 --- a/lexicon/providers/joker.py +++ b/lexicon/providers/joker.py @@ -19,7 +19,8 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/linode.py b/lexicon/providers/linode.py index 2e741eec4..e486578b3 100644 --- a/lexicon/providers/linode.py +++ b/lexicon/providers/linode.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/linode4.py b/lexicon/providers/linode4.py index f23ce4f42..ff963de4e 100644 --- a/lexicon/providers/linode4.py +++ b/lexicon/providers/linode4.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/luadns.py b/lexicon/providers/luadns.py index 6e409cbce..7c60ad1f2 100644 --- a/lexicon/providers/luadns.py +++ b/lexicon/providers/luadns.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/memset.py b/lexicon/providers/memset.py index 50a43f72c..7fd5f966b 100644 --- a/lexicon/providers/memset.py +++ b/lexicon/providers/memset.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/mythicbeasts.py b/lexicon/providers/mythicbeasts.py index 325e14fb1..db420bd26 100644 --- a/lexicon/providers/mythicbeasts.py +++ b/lexicon/providers/mythicbeasts.py @@ -9,7 +9,8 @@ from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry # type: ignore -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/namecheap.py b/lexicon/providers/namecheap.py index 2975a8dbb..4b0ea2c54 100644 --- a/lexicon/providers/namecheap.py +++ b/lexicon/providers/namecheap.py @@ -6,7 +6,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/namesilo.py b/lexicon/providers/namesilo.py index e6410d6b7..aa577d490 100644 --- a/lexicon/providers/namesilo.py +++ b/lexicon/providers/namesilo.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/netcup.py b/lexicon/providers/netcup.py index 91630fd63..2c5539136 100644 --- a/lexicon/providers/netcup.py +++ b/lexicon/providers/netcup.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/nfsn.py b/lexicon/providers/nfsn.py index c7f243587..c060f9e2b 100644 --- a/lexicon/providers/nfsn.py +++ b/lexicon/providers/nfsn.py @@ -9,7 +9,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/njalla.py b/lexicon/providers/njalla.py index 733112c8b..cc457f632 100644 --- a/lexicon/providers/njalla.py +++ b/lexicon/providers/njalla.py @@ -3,7 +3,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/nsone.py b/lexicon/providers/nsone.py index 15b190fa7..004347191 100644 --- a/lexicon/providers/nsone.py +++ b/lexicon/providers/nsone.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/onapp.py b/lexicon/providers/onapp.py index b1ab43c9a..a42d1d068 100644 --- a/lexicon/providers/onapp.py +++ b/lexicon/providers/onapp.py @@ -6,7 +6,8 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/ovh.py b/lexicon/providers/ovh.py index 3707e0a7f..cd9f0f0eb 100644 --- a/lexicon/providers/ovh.py +++ b/lexicon/providers/ovh.py @@ -6,7 +6,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/plesk.py b/lexicon/providers/plesk.py index 64c332171..86fbf3cb4 100644 --- a/lexicon/providers/plesk.py +++ b/lexicon/providers/plesk.py @@ -13,7 +13,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/pointhq.py b/lexicon/providers/pointhq.py index 98debeeee..765884336 100644 --- a/lexicon/providers/pointhq.py +++ b/lexicon/providers/pointhq.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/rackspace.py b/lexicon/providers/rackspace.py index e2daf37ec..c818552c6 100644 --- a/lexicon/providers/rackspace.py +++ b/lexicon/providers/rackspace.py @@ -5,7 +5,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/rage4.py b/lexicon/providers/rage4.py index 707342b58..e6b0f9ada 100644 --- a/lexicon/providers/rage4.py +++ b/lexicon/providers/rage4.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/route53.py b/lexicon/providers/route53.py index 7142523c3..903445150 100644 --- a/lexicon/providers/route53.py +++ b/lexicon/providers/route53.py @@ -3,7 +3,8 @@ import logging import re -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError try: import boto3 # type: ignore diff --git a/lexicon/providers/safedns.py b/lexicon/providers/safedns.py index 8cf0d8907..3f1c18455 100644 --- a/lexicon/providers/safedns.py +++ b/lexicon/providers/safedns.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/sakuracloud.py b/lexicon/providers/sakuracloud.py index 66d5c0e2c..8d5005ca2 100644 --- a/lexicon/providers/sakuracloud.py +++ b/lexicon/providers/sakuracloud.py @@ -5,7 +5,8 @@ import requests from requests.auth import HTTPBasicAuth -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/softlayer.py b/lexicon/providers/softlayer.py index 258f1a16c..d1a5d4e8b 100644 --- a/lexicon/providers/softlayer.py +++ b/lexicon/providers/softlayer.py @@ -1,7 +1,8 @@ """Module provider for Softlayer""" import logging -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError try: import SoftLayer # type: ignore diff --git a/lexicon/providers/transip.py b/lexicon/providers/transip.py index 142a403e8..3080d82cd 100644 --- a/lexicon/providers/transip.py +++ b/lexicon/providers/transip.py @@ -2,7 +2,8 @@ import logging from typing import List -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError # Support various versions of Transip Python API try: diff --git a/lexicon/providers/vultr.py b/lexicon/providers/vultr.py index cd692972e..1a6895df1 100644 --- a/lexicon/providers/vultr.py +++ b/lexicon/providers/vultr.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/yandex.py b/lexicon/providers/yandex.py index 33226b731..e5a78c36c 100644 --- a/lexicon/providers/yandex.py +++ b/lexicon/providers/yandex.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError __author__ = "Aliaksandr Kharkevich" __license__ = "MIT" diff --git a/lexicon/providers/zeit.py b/lexicon/providers/zeit.py index 19552e002..7c1de4c6f 100644 --- a/lexicon/providers/zeit.py +++ b/lexicon/providers/zeit.py @@ -4,7 +4,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/zilore.py b/lexicon/providers/zilore.py index e0741faac..e91411f41 100644 --- a/lexicon/providers/zilore.py +++ b/lexicon/providers/zilore.py @@ -3,7 +3,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__) diff --git a/lexicon/providers/zonomi.py b/lexicon/providers/zonomi.py index 8d0fa23b6..ca4aa89d3 100644 --- a/lexicon/providers/zonomi.py +++ b/lexicon/providers/zonomi.py @@ -22,7 +22,8 @@ import requests -from lexicon.providers.base import Provider as BaseProvider, AuthenticationError +from lexicon.providers.base import Provider as BaseProvider +from lexicon.exceptions import AuthenticationError LOGGER = logging.getLogger(__name__)