diff options
author | Dan McGee <dan@archlinux.org> | 2010-10-07 15:07:03 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-10-07 15:07:03 +0200 |
commit | 2e299273e2462775cf3ecd4f93715678575319fd (patch) | |
tree | 49b3c39e6e758f11f23d6ea01f904bf5eea43f91 /mirrors/management/commands | |
parent | 5fce0e249c3fef4dff65720115dccb27d298c312 (diff) | |
download | archweb-2e299273e2462775cf3ecd4f93715678575319fd.tar.gz archweb-2e299273e2462775cf3ecd4f93715678575319fd.tar.xz |
mirrorcheck: record duration on file not found errors
On an HTTP 404, FTP 550, or inability to parse the lastsync file, record the
duration of the check even though we couldn't get a time from the mirror.
This allows for these checks to show up as completed but in error, which is
more what.
Previously, inability to parse the date was also recorded as a success, so
change that to be a failure and record an error message with it.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/management/commands')
-rw-r--r-- | mirrors/management/commands/mirrorcheck.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py index 1662b15..210505f 100644 --- a/mirrors/management/commands/mirrorcheck.py +++ b/mirrors/management/commands/mirrorcheck.py @@ -20,6 +20,7 @@ import sys import time import thread from threading import Thread +import types from Queue import Queue, Empty import urllib2 @@ -81,6 +82,7 @@ def check_mirror_url(mirror_url): # lastsync should be an epoch value, but some mirrors # are creating their own in RFC-3339 format: # '2010-09-02 11:05:06+02:00' + parsed_time = None try: parsed_time = datetime.utcfromtimestamp(int(data)) except ValueError: @@ -91,15 +93,28 @@ def check_mirror_url(mirror_url): parsed_time = parse_rfc3339_datetime(data) log.last_sync = parsed_time + # if we couldn't parse a time, this is a failure + if parsed_time == None: + log.error = "Could not parse time from lastsync" + log.is_success = False log.duration = end - start logger.debug("success: %s, %.2f" % (url, log.duration)) except urllib2.HTTPError, e: + if e.code == 404: + # we have a duration, just not a success + end = time.time() + log.duration = end - start log.is_success = False - log.error =str(e) + log.error = str(e) logger.debug("failed: %s, %s" % (url, log.error)) except urllib2.URLError, e: log.is_success=False log.error = e.reason + if isinstance(e.reason, types.StringTypes) and \ + re.search(r'550.*No such file', e.reason): + # similar to 404 case above, still record duration + end = time.time() + log.duration = end - start if isinstance(e.reason, socket.timeout): log.error = "Connection timed out." elif isinstance(e.reason, socket.error): |