From 48a80d7e44b2029cb08ae7aa62a0aca1f5270060 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Sat, 26 Feb 2022 08:48:22 +0100 Subject: [PATCH] fix loopia acme script for new error handling --- files/acme-auth-loopia.py | 10 +++++++--- files/acme-cleanup-loopia.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/files/acme-auth-loopia.py b/files/acme-auth-loopia.py index 50a8957..21509bf 100755 --- a/files/acme-auth-loopia.py +++ b/files/acme-auth-loopia.py @@ -71,14 +71,18 @@ def main(): parts=[] while domain: - res = client.getSubdomains(user, pwd, domain) - if 'UNKNOWN_ERROR' not in res: + try: + res = client.getSubdomains(user, pwd, domain) + except xmlrpc.client.Fault as err: + if err.faultCode != 404: + raise err + else: break part, domain = domain.split('.', maxsplit=1) parts.append(part) subdomain = '_acme-challenge.{}'.format('.'.join(parts)) - if 'UNKNOWN_ERROR' in res: + if not res: print("Failed to find domain in loopiadns") return 1 diff --git a/files/acme-cleanup-loopia.py b/files/acme-cleanup-loopia.py index 3836987..2549f82 100755 --- a/files/acme-cleanup-loopia.py +++ b/files/acme-cleanup-loopia.py @@ -58,14 +58,18 @@ def main(): parts=[] while domain: - res = client.getSubdomains(user, pwd, domain) - if 'UNKNOWN_ERROR' not in res: + try: + res = client.getSubdomains(user, pwd, domain) + except xmlrpc.client.Fault as err: + if err.faultCode != 404: + raise err + else: break part, domain = domain.split('.', maxsplit=1) parts.append(part) subdomain = '_acme-challenge.{}'.format('.'.join(parts)) - if 'UNKNOWN_ERROR' in res: + if not res: print("Failed to find domain in loopiadns") return 1