From aab918351f04bb7f4d0c381738e5d229e67306d9 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 24 Jul 2023 18:21:46 -0400 Subject: [PATCH] text encoding --- src/config.py | 14 +++++++------- src/gandi-live-dns.py | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/config.py b/src/config.py index a63f363..f4eb9c9 100644 --- a/src/config.py +++ b/src/config.py @@ -1,10 +1,10 @@ import os -api_secret = os.environ.get("GANDI_API_SECRET", "TOKEN") -api_endpoint = os.environ.get("GANDI_API_ENDPOINT",'https://dns.api.gandi.net/api/v5') +api_secret = os.environ.get("GANDI_API_SECRET", "TOKEN").replace("\"","") +api_endpoint = os.environ.get("GANDI_API_ENDPOINT",'https://dns.api.gandi.net/api/v5').replace("\"","") -static_ip = os.environ.get("GANDI_STATIC_IP","") -domain = os.environ.get("GANDI_DOMAIN","") -subdomains = os.environ.get("GANDI_SUBDOMAINS","").split(",") -ttl = os.environ.get("GANDI_TIMEOUT","300") -ifconfig = os.environ.get("GANDI_IFCONFIG","https://ifconfig.co/ip") +static_ip = os.environ.get("GANDI_STATIC_IP","").replace("\"","") +domain = os.environ.get("GANDI_DOMAIN","").replace("\"","") +subdomains = os.environ.get("GANDI_SUBDOMAINS","").replace("\"","").split(",") +ttl = os.environ.get("GANDI_TIMEOUT","300").replace("\"","") +ifconfig = os.environ.get("GANDI_IFCONFIG","https://ifconfig.co/ip").replace("\"","") diff --git a/src/gandi-live-dns.py b/src/gandi-live-dns.py index a3d7a07..365e7b2 100755 --- a/src/gandi-live-dns.py +++ b/src/gandi-live-dns.py @@ -59,8 +59,8 @@ def get_dnsip(uuid): u = requests.get(url, headers=headers) if u.status_code == 200: json_object = json.loads(u._content) - print('Checking IP from DNS Record' , config.subdomains[0], ':', json_object['rrset_values'][0].encode('ascii','ignore').strip('\n')) - return json_object['rrset_values'][0].encode('ascii','ignore').strip('\n') + print('Checking IP from DNS Record' , config.subdomains[0], ':', json_object['rrset_values'][0].encode('ascii','ignore').decode().strip('\n')) + return json_object['rrset_values'][0].strip('\n') else: print('Error: HTTP Status Code ', u.status_code, 'when trying to get IP from subdomain', config.subdomains[0]) print(json_object['message']) @@ -96,7 +96,6 @@ def main(force_update, verbosity): if verbosity: print("verbosity turned on - not implemented by now") - #get zone ID from Account uuid = get_uuid()