diff options
author | Magdalena GrodziĆska <mag.grodzinska@gmail.com> | 2019-11-24 21:14:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-24 21:14:47 +0100 |
commit | 9e678a942e98d78ad0ac81e7ffb0be551db88162 (patch) | |
tree | bda0c99a553938b9467e224c419f59bd2640de38 /src | |
parent | c1a662b6d3652256c7a2f6147abbbb1832c624e0 (diff) | |
parent | 04dcb225a99c2e4531140828665b33dbf1ac56de (diff) |
Merge pull request #38 from m-chrzan/secure_fetcher
Add try except clause to domain name fetch
Diffstat (limited to 'src')
-rw-r--r-- | src/main/resources/pl/edu/mimuw/cloudatlas/fetcher/data_fetcher.py | 11 |
1 files changed, 8 insertions, 3 deletions
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, |