diff options
author | Dan McGee <dan@archlinux.org> | 2011-02-27 12:44:30 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-02-27 12:44:30 -0600 |
commit | 6d5909ca5dc8934cacd969e964573989dc6b0417 (patch) | |
tree | 69bba97e24b6ae67861884bf93362f5274c78309 /mirrors/management | |
parent | db1524fd64e8b5c0f43cfed7643034ee764f55fd (diff) |
Auto-resolve mirror URLs on save
This prevents people from having to mess with these checkboxes at all in
the admin, and we incur no delay on their initial values being correct
waiting for the cron job to run.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/management')
-rw-r--r-- | mirrors/management/commands/mirrorresolv.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/mirrors/management/commands/mirrorresolv.py b/mirrors/management/commands/mirrorresolv.py index 77e7a223..8a628bd4 100644 --- a/mirrors/management/commands/mirrorresolv.py +++ b/mirrors/management/commands/mirrorresolv.py @@ -12,7 +12,6 @@ from django.core.management.base import NoArgsCommand import sys import logging -from urlparse import urlparse import socket from mirrors.models import MirrorUrl @@ -42,13 +41,11 @@ def resolve_mirrors(): logger.debug("requesting list of mirror URLs") for mirrorurl in MirrorUrl.objects.filter(mirror__active=True): try: - hostname = urlparse(mirrorurl.url).hostname - logger.debug("resolving %3i (%s)", mirrorurl.id, hostname) - info = socket.getaddrinfo(hostname, None, 0, socket.SOCK_STREAM) - families = [x[0] for x in info] + logger.debug("resolving %3i (%s)", mirrorurl.id, mirrorurl.hostname) + families = mirrorurl.address_families() mirrorurl.has_ipv4 = socket.AF_INET in families mirrorurl.has_ipv6 = socket.AF_INET6 in families - logger.debug("%s: v4: %s v6: %s", hostname, + logger.debug("%s: v4: %s v6: %s", mirrorurl.hostname, mirrorurl.has_ipv4, mirrorurl.has_ipv6) mirrorurl.save(force_update=True) except socket.error, e: |