From 6b53bcf359831bc31d0f92eb851cf67e8e03bda6 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Sat, 14 Jan 2017 00:13:45 +0100 Subject: [PATCH] Socket test if host is online --- bin/crawl.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/crawl.py b/bin/crawl.py index 550b525..913f91f 100755 --- a/bin/crawl.py +++ b/bin/crawl.py @@ -12,6 +12,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dnmapper.settings") import django django.setup() +import socket import datetime from django.utils import timezone from django.db.models import Q, Max @@ -56,6 +57,11 @@ def main(): print("%s: %s" % (host, msg)) CrawlLog.log(crawl, msg, host=host, severity=CrawlLog.ERROR) continue + except socket.error as e: + msg = "Could not reach host: %s" % (e,) + print("%s: %s" % (host, msg)) + CrawlLog.log(crawl, msg, host=host, severity=CrawlLog.ERROR) + continue print(" -- parsing...")