summaryrefslogtreecommitdiffstats
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-31 22:10:48 +0100
committerDan McGee <dan@archlinux.org>2011-01-31 22:10:48 +0100
commit0bb5e9fd6dfa5f5e3be8a9e9c7f0f7ea8ec37733 (patch)
tree4d71828af55b7b631c0cd9623567ce83952a09e8 /mirrors
parent7d043be0b3d090d2f675af5b86856693aa73e787 (diff)
downloadarchweb-0bb5e9fd6dfa5f5e3be8a9e9c7f0f7ea8ec37733.tar.gz
archweb-0bb5e9fd6dfa5f5e3be8a9e9c7f0f7ea8ec37733.tar.xz
Defer format string substitution to logger
Don't use 'fmtstr % (arg1, arg2)' type format; logger can be passed a format string and the arguments to populate it. Saves a bit of work for strings that never end up getting displayed anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/management/commands/mirrorcheck.py12
-rw-r--r--mirrors/management/commands/mirrorresolv.py6
2 files changed, 10 insertions, 8 deletions
diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py
index d7aad4e..44d2b36 100644
--- a/mirrors/management/commands/mirrorcheck.py
+++ b/mirrors/management/commands/mirrorcheck.py
@@ -68,7 +68,7 @@ def parse_rfc3339_datetime(time_string):
def check_mirror_url(mirror_url):
url = mirror_url.url + 'lastsync'
- logger.info("checking URL %s" % url)
+ logger.info("checking URL %s", url)
log = MirrorLog(url=mirror_url, check_time=datetime.utcnow())
try:
start = time.time()
@@ -86,7 +86,7 @@ def check_mirror_url(mirror_url):
# it is bad news to try logging the lastsync value;
# sometimes we get a crazy-encoded web page.
logger.info("attempting to parse generated lastsync file"
- " from mirror %s" % url)
+ " from mirror %s", url)
parsed_time = parse_rfc3339_datetime(data)
log.last_sync = parsed_time
@@ -95,7 +95,7 @@ def check_mirror_url(mirror_url):
log.error = "Could not parse time from lastsync"
log.is_success = False
log.duration = end - start
- logger.debug("success: %s, %.2f" % (url, log.duration))
+ logger.debug("success: %s, %.2f", url, log.duration)
except urllib2.HTTPError, e:
if e.code == 404:
# we have a duration, just not a success
@@ -103,7 +103,7 @@ def check_mirror_url(mirror_url):
log.duration = end - start
log.is_success = False
log.error = str(e)
- logger.debug("failed: %s, %s" % (url, log.error))
+ logger.debug("failed: %s, %s", url, log.error)
except urllib2.URLError, e:
log.is_success = False
log.error = e.reason
@@ -116,11 +116,11 @@ def check_mirror_url(mirror_url):
log.error = "Connection timed out."
elif isinstance(e.reason, socket.error):
log.error = e.reason.args[1]
- logger.debug("failed: %s, %s" % (url, log.error))
+ logger.debug("failed: %s, %s", url, log.error)
except socket.timeout, e:
log.is_success = False
log.error = "Connection timed out."
- logger.debug("failed: %s, %s" % (url, log.error))
+ logger.debug("failed: %s, %s", url, log.error)
return log
diff --git a/mirrors/management/commands/mirrorresolv.py b/mirrors/management/commands/mirrorresolv.py
index bcb24a5..8cbd51a 100644
--- a/mirrors/management/commands/mirrorresolv.py
+++ b/mirrors/management/commands/mirrorresolv.py
@@ -43,13 +43,15 @@ def resolve_mirrors():
for mirrorurl in MirrorUrl.objects.filter(mirror__active=True):
try:
hostname = urlparse(mirrorurl.url).hostname
- logger.debug("resolving %3i (%s)" % (mirrorurl.id, 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]
mirrorurl.has_ipv4 = socket.AF_INET in families
mirrorurl.has_ipv6 = socket.AF_INET6 in families
+ logger.debug("%s: v4: %s v6: %s", hostname,
+ mirrorurl.has_ipv4, mirrorurl.has_ipv6)
mirrorurl.save()
except socket.error, e:
- logger.warn("error resolving %s: %s" % (hostname, e))
+ logger.warn("error resolving %s: %s", hostname, e)
# vim: set ts=4 sw=4 et: