From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/mirrorselect:master commit in: mirrorselect/
Date: Fri, 18 Oct 2013 06:46:17 +0000 (UTC) [thread overview]
Message-ID: <1382078723.17023eb1d83d99cc92d2d9e09bf8e2c47227d88c.dol-sen@gentoo> (raw)
commit: 17023eb1d83d99cc92d2d9e09bf8e2c47227d88c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 18 06:45:23 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Oct 18 06:45:23 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/mirrorselect.git;a=commit;h=17023eb1
refactor Deep classes deeptime()
fixes many errors, including dns errors on some systems,
Adds improved debug reporting.
Adds total download failures output to the results.
---
mirrorselect/selectors.py | 65 +++++++++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 28 deletions(-)
diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py
index 2c7bac8..4da6156 100644
--- a/mirrorselect/selectors.py
+++ b/mirrorselect/selectors.py
@@ -39,11 +39,13 @@ import hashlib
if sys.version_info[0] >= 3:
import urllib.request, urllib.parse, urllib.error
url_parse = urllib.parse.urlparse
+ url_unparse = urllib.parse.urlunparse
url_open = urllib.request.urlopen
else:
import urllib
import urlparse
url_parse = urlparse.urlparse
+ url_unparse = urlparse.urlunparse
url_open = urllib.urlopen
@@ -200,9 +202,7 @@ class Deep(object):
elif options.ipv6:
addr_families.append(socket.AF_INET6)
else:
- addr_families.append(socket.AF_INET)
- if socket.has_ipv6:
- addr_families.append(socket.AF_INET6)
+ addr_families.append(socket.AF_UNSPEC)
self._addr_families = addr_families
@@ -219,6 +219,7 @@ class Deep(object):
maxtime = self._download_timeout
hosts = [host[0] for host in self._hosts]
num_hosts = len(hosts)
+ self.dl_failures = 0
for host in hosts:
@@ -252,7 +253,9 @@ class Deep(object):
#self.output.write('deeptest(): adding rethost %s, %s' % (key, top_hosts[key]), 2)
rethosts.append(top_hosts[key])
- self.output.write('deeptest(): final rethost %s' % (rethosts), 2)
+ self.output.write('deeptest(): final rethost %s\n' % (rethosts), 2)
+ self.output.write('deeptest(): final md5 failures %s of %s\n'
+ % (self.dl_failures, num_hosts), 2)
self.urls = rethosts
@@ -280,40 +283,38 @@ class Deep(object):
signal.signal(signal.SIGALRM, timeout_handler)
ips = []
- for family in self._addr_families:
- ipv6 = family == socket.AF_INET6
+ for addr_family in self._addr_families:
try:
- try:
- signal.alarm(self._dns_timeout)
- for family, socktype, proto, canonname, sockaddr in \
- socket.getaddrinfo(url_parts.hostname, None,
- family, socket.SOCK_STREAM):
- ip = sockaddr[0]
- if ipv6:
- ip = "[%s]" % ip
- ips.append(ip)
- finally:
- signal.alarm(0)
+ signal.alarm(self._dns_timeout)
+ for result in socket.getaddrinfo(url_parts.hostname, None,
+ addr_family, socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG):
+ family, _, __, ___, sockaddr = result
+ ip = sockaddr[0]
+ if family == socket.AF_INET6:
+ ip = "[%s]" % ip
+ ips.append(ip)
except socket.error as e:
- self.output.write('deeptime(): dns error for host %s: %s\n' % \
- (url_parts.hostname, e), 2)
+ self.output.write('deeptime(): dns error for host %s: %s\n' % (url_parts.hostname, e), 2)
except TimeoutException:
- self.output.write('deeptime(): dns timeout for host %s\n' % \
- (url_parts.hostname,), 2)
+ self.output.write('deeptime(): dns timeout for host %s\n' % url_parts.hostname, 2)
+ finally:
+ signal.alarm(0)
if not ips:
- self.output.write('deeptime(): unable to resolve ip for host %s\n' % \
- (url_parts.hostname,), 2)
+ self.output.write('deeptime(): unable to resolve ip for host %s\n' % url_parts.hostname, 2)
return (None, True)
delta = 0
f = None
for ip in ips:
+ test_parts = url_parts._replace(netloc=ip)
+ test_url = url_unparse(test_parts)
+ self.output.write('deeptime(): testing url: %s\n' % test_url, 2)
try:
try:
signal.alarm(self._connect_timeout)
- f = url_open(url)
+ f = url_open(test_url)
break
finally:
signal.alarm(0)
@@ -324,7 +325,7 @@ class Deep(object):
except TimeoutException:
self.output.write(('deeptime(): connection to host %s ' + \
'timed out for ip %s\n') % \
- (url_parts.hostname, ip), 2)
+ (test_parts.hostname, ip), 2)
if f is None:
self.output.write('deeptime(): unable to ' + \
@@ -355,13 +356,21 @@ class Deep(object):
try:
signal.alarm(int(math.ceil(maxtime)))
stime = time.time()
- f = url_open(url)
+ f = url_open(test_url)
- if hashlib.md5(f.read()).hexdigest() != "bdf077b2e683c506bf9e8f2494eeb044":
- return (None, True)
+ md5 = hashlib.md5(f.read()).hexdigest()
delta = time.time() - stime
f.close()
+ if md5 != self.test_md5:
+ self.output.write(
+ "deeptime(): md5sum error for file: %s\n" % self.test_file +
+ " expected: %s\n" % self.test_md5 +
+ " got.....: %s\n" % md5 +
+ " host....: %s, %s\n" % (url_parts.hostname, ip))
+ self.dl_failures += 1
+ return (None, True)
+
finally:
signal.alarm(0)
next reply other threads:[~2013-10-18 6:46 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-18 6:46 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-05-28 3:48 [gentoo-commits] proj/mirrorselect:master commit in: mirrorselect/ Sam James
2023-08-07 0:23 Sam James
2023-08-07 0:14 Sam James
2023-08-07 0:14 Sam James
2023-08-07 0:14 Sam James
2023-08-06 23:30 Sam James
2023-08-06 23:30 Sam James
2023-07-06 8:05 Sam James
2022-05-31 18:39 Brian Dolbec
2022-05-31 18:39 Brian Dolbec
2022-05-31 18:39 Brian Dolbec
2022-05-31 18:39 Brian Dolbec
2022-05-31 4:08 Brian Dolbec
2022-05-31 4:08 Brian Dolbec
2022-05-31 2:22 Brian Dolbec
2022-05-31 2:22 Brian Dolbec
2022-05-30 23:12 Brian Dolbec
2022-05-30 23:12 Brian Dolbec
2020-06-03 19:05 Brian Dolbec
2019-07-17 5:06 Zac Medico
2019-05-27 17:52 Zac Medico
2019-05-27 17:22 Zac Medico
2019-02-13 8:22 Zac Medico
2019-02-13 8:09 Zac Medico
2019-02-13 5:51 Zac Medico
2018-05-26 15:43 Brian Dolbec
2017-02-21 4:44 Zac Medico
2017-02-21 3:19 Brian Dolbec
2017-02-21 3:19 Brian Dolbec
2016-11-15 1:16 Zac Medico
2015-01-27 18:20 Brian Dolbec
2015-01-27 4:38 Brian Dolbec
2015-01-27 4:38 Brian Dolbec
2014-05-28 21:08 Brian Dolbec
2014-05-28 19:44 Brian Dolbec
2014-05-05 2:04 Brian Dolbec
2014-05-05 2:04 Brian Dolbec
2014-05-05 2:04 Brian Dolbec
2014-03-02 7:44 [gentoo-commits] proj/mirrorselect:ssl " Brian Dolbec
2014-03-02 7:44 ` [gentoo-commits] proj/mirrorselect:master " Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-03-02 7:44 Brian Dolbec
2014-01-31 15:44 [gentoo-commits] proj/mirrorselect:ssl " Brian Dolbec
2014-03-02 7:44 ` [gentoo-commits] proj/mirrorselect:master " Brian Dolbec
2013-10-20 18:19 [gentoo-commits] proj/mirrorselect:ssl " Brian Dolbec
2014-03-02 7:44 ` [gentoo-commits] proj/mirrorselect:master " Brian Dolbec
2013-10-19 9:06 Brian Dolbec
2013-10-19 9:06 Brian Dolbec
2013-10-19 9:06 Brian Dolbec
2013-10-18 14:26 Brian Dolbec
2013-10-18 6:46 Brian Dolbec
2013-10-18 6:46 Brian Dolbec
2013-10-18 6:46 Brian Dolbec
2013-10-17 14:26 Brian Dolbec
2013-10-17 6:57 Brian Dolbec
2013-10-17 3:16 Brian Dolbec
2013-10-17 3:16 Brian Dolbec
2013-10-17 3:16 Brian Dolbec
2013-10-16 9:17 Brian Dolbec
2013-10-16 8:36 Brian Dolbec
2013-10-16 8:36 Brian Dolbec
2013-10-16 8:36 Brian Dolbec
2013-10-16 8:36 Brian Dolbec
2013-10-15 22:43 Brian Dolbec
2013-10-15 14:39 Brian Dolbec
2013-10-15 14:39 Brian Dolbec
2013-10-15 14:39 Brian Dolbec
2013-10-15 7:27 Brian Dolbec
2013-10-15 3:51 Brian Dolbec
2013-10-15 3:51 Brian Dolbec
2013-03-10 13:07 Brian Dolbec
2012-12-16 2:38 Brian Dolbec
2012-12-15 21:25 Brian Dolbec
2012-11-15 3:53 Brian Dolbec
2012-11-15 3:44 Brian Dolbec
2012-11-14 20:28 Paul Varner
2012-11-12 21:41 Brian Dolbec
2012-11-12 20:37 Brian Dolbec
2012-11-12 15:56 Brian Dolbec
2012-11-12 7:46 Brian Dolbec
2012-11-12 7:46 Brian Dolbec
2012-11-12 7:46 Brian Dolbec
2012-11-12 7:46 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1382078723.17023eb1d83d99cc92d2d9e09bf8e2c47227d88c.dol-sen@gentoo \
--to=brian.dolbec@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox