summaryrefslogtreecommitdiffstats
path: root/mirrors/management/commands
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-04-17 05:12:01 +0200
committerDan McGee <dan@archlinux.org>2013-04-17 05:12:01 +0200
commitb7b24740640e24883cd17fd683e1d465fbb343f8 (patch)
tree0a8a4fdf23f3a3b7f0551e859c36c23e3afe212f /mirrors/management/commands
parent31d39e75eea7fb6cdf3bb8bfd8b490d45de04ee9 (diff)
downloadarchweb-b7b24740640e24883cd17fd683e1d465fbb343f8.tar.gz
archweb-b7b24740640e24883cd17fd683e1d465fbb343f8.tar.xz
Various minor code cleanups and fixes
Most of these were suggested by PyCharm, and include everything from little syntax issues and other bad smells to dead or bad code. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/management/commands')
-rw-r--r--mirrors/management/commands/mirrorcheck.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py
index d6de8f2..e7dd7b4 100644
--- a/mirrors/management/commands/mirrorcheck.py
+++ b/mirrors/management/commands/mirrorcheck.py
@@ -106,19 +106,13 @@ def parse_lastsync(log, data):
def check_mirror_url(mirror_url, location, timeout):
- if location:
- if location.family == socket.AF_INET6:
- ipopt = '--ipv6'
- elif location.family == socket.AF_INET:
- ipopt = '--ipv4'
-
url = mirror_url.url + 'lastsync'
logger.info("checking URL %s", url)
log = MirrorLog(url=mirror_url, check_time=now(), location=location)
headers = {'User-Agent': 'archweb/1.0'}
req = urllib2.Request(url, None, headers)
+ start = time.time()
try:
- start = time.time()
result = urllib2.urlopen(req, timeout=timeout)
data = result.read()
result.close()
@@ -147,12 +141,12 @@ def check_mirror_url(mirror_url, location, timeout):
elif isinstance(e.reason, socket.error):
log.error = e.reason.args[1]
logger.debug("failed: %s, %s", url, log.error)
- except HTTPException as e:
+ except HTTPException:
# e.g., BadStatusLine
log.is_success = False
log.error = "Exception in processing HTTP request."
logger.debug("failed: %s, %s", url, log.error)
- except socket.timeout as e:
+ except socket.timeout:
log.is_success = False
log.error = "Connection timed out."
logger.debug("failed: %s, %s", url, log.error)