From 04dcb225a99c2e4531140828665b33dbf1ac56de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 24 Nov 2019 21:05:48 +0100 Subject: Add try except clause to domain name fetch --- .../resources/pl/edu/mimuw/cloudatlas/fetcher/data_fetcher.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main/resources/pl') diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/fetcher/data_fetcher.py b/src/main/resources/pl/edu/mimuw/cloudatlas/fetcher/data_fetcher.py index 67b2eb4..d53ce05 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/fetcher/data_fetcher.py +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/fetcher/data_fetcher.py @@ -64,9 +64,14 @@ def get_data(): kernel_ver = platform.release() logged_users = len(psutil.users()) - external_ip = urllib.request.urlopen('https://ident.me').read().decode('utf8') - hostname = socket.gethostbyaddr(external_ip) - dns_names = ([hostname[0]] + hostname[1])[:3] + try: + external_ip = urllib.request.urlopen('https://ident.me').read().decode('utf8') + hostname = socket.gethostbyaddr(external_ip) + dns_names = ([hostname[0]] + hostname[1])[:3] + except Exception as e: + pass + else: + dns_names = [] sys.stdout.write("[{},{},{},{},{},{},{},{},{},{},{},{}]\n".format( avg_load, -- cgit v1.2.3