Socket test if host is online

This commit is contained in:
Sebastian Lohff 2017-01-14 00:13:45 +01:00
parent 2fea65579b
commit 6b53bcf359
1 changed files with 6 additions and 0 deletions

View File

@ -12,6 +12,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dnmapper.settings")
import django import django
django.setup() django.setup()
import socket
import datetime import datetime
from django.utils import timezone from django.utils import timezone
from django.db.models import Q, Max from django.db.models import Q, Max
@ -56,6 +57,11 @@ def main():
print("%s: %s" % (host, msg)) print("%s: %s" % (host, msg))
CrawlLog.log(crawl, msg, host=host, severity=CrawlLog.ERROR) CrawlLog.log(crawl, msg, host=host, severity=CrawlLog.ERROR)
continue 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...") print(" -- parsing...")