From 47294c4e7af4db6f2ce6f15afb9e40a587f4b910 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 11 Jun 2020 10:44:36 +0200 Subject: [PATCH 1/2] Timestamp log entries --- src/ddns_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ddns_update.py b/src/ddns_update.py index ba37e50..1893144 100755 --- a/src/ddns_update.py +++ b/src/ddns_update.py @@ -9,7 +9,7 @@ from netifaces import interfaces, ifaddresses, AF_INET6 from ipaddress import ip_address from time import sleep -logging.basicConfig(level=logging.INFO) +logging.basicConfig(level=logging.INFO, format="%(asctime)-15s - %(name)s %(levelname)-8s: %(message)s") log = logging.getLogger("ddns updater") From 4399130373869cb80b8b997362ba9c10bd0d9f50 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 11 Jun 2020 10:47:07 +0200 Subject: [PATCH 2/2] Report connection errors when no response object is available --- src/ddns_update.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ddns_update.py b/src/ddns_update.py index ba37e50..1c1763a 100755 --- a/src/ddns_update.py +++ b/src/ddns_update.py @@ -33,10 +33,15 @@ def response_successful(response_text): def ddns_update(host, key, ip): - url = f"https://dyndns.strato.com/nic/update?hostname={host}&myip={ip}" + url = f"https://dyndns.strato_.com/nic/update?hostname={host}&myip={ip}" try: response = requests.get(url, auth=(host, key), timeout=3) + except RequestException as error: + log.error(error) + return False + + try: response.raise_for_status() if not response_successful(response.text):