1 |
commit: 3445069b3da6a33356f2d16a9ff27a722873512d |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon May 5 02:03:01 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Mon May 5 02:03:01 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/mirrorselect.git;a=commit;h=3445069b |
7 |
|
8 |
selectors.py: Add IncompleteRead exception |
9 |
|
10 |
Improve output formatting. |
11 |
|
12 |
--- |
13 |
mirrorselect/selectors.py | 14 +++++++++++--- |
14 |
1 file changed, 11 insertions(+), 3 deletions(-) |
15 |
|
16 |
diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py |
17 |
index 5d30695..1aa5f11 100644 |
18 |
--- a/mirrorselect/selectors.py |
19 |
+++ b/mirrorselect/selectors.py |
20 |
@@ -42,6 +42,8 @@ if sys.version_info[0] >= 3: |
21 |
url_unparse = urllib.parse.urlunparse |
22 |
url_open = urllib.request.urlopen |
23 |
HTTPError = urllib.error.HTTPError |
24 |
+ import http.client |
25 |
+ IncompleteRead = http.client.IncompleteRead |
26 |
else: |
27 |
import urllib2 |
28 |
import urlparse |
29 |
@@ -49,6 +51,8 @@ else: |
30 |
url_unparse = urlparse.urlunparse |
31 |
url_open = urllib2.urlopen |
32 |
HTTPError = urllib2.HTTPError |
33 |
+ import httplib |
34 |
+ IncompleteRead = httplib.IncompleteRead |
35 |
|
36 |
|
37 |
from mirrorselect.output import encoder, get_encoding, decode_selection |
38 |
@@ -369,7 +373,7 @@ class Deep(object): |
39 |
f.close() |
40 |
if md5 != self.test_md5: |
41 |
self.output.write( |
42 |
- "deeptime(): md5sum error for file: %s\n" |
43 |
+ "\ndeeptime(): md5sum error for file: %s\n" |
44 |
% self.test_file + |
45 |
" expected: %s\n" % self.test_md5 + |
46 |
" got.....: %s\n" % md5 + |
47 |
@@ -382,13 +386,17 @@ class Deep(object): |
48 |
signal.alarm(0) |
49 |
|
50 |
except EnvironmentError as e: |
51 |
- self.output.write(('deeptime(): download from host %s ' |
52 |
+ self.output.write(('\ndeeptime(): download from host %s ' |
53 |
'failed for ip %s: %s\n') % (url_parts.hostname, ip, e), 2) |
54 |
return (None, True) |
55 |
except TimeoutException: |
56 |
- self.output.write(('deeptime(): download from host %s ' |
57 |
+ self.output.write(('\ndeeptime(): download from host %s ' |
58 |
'timed out for ip %s\n') % (url_parts.hostname, ip), 2) |
59 |
return (None, True) |
60 |
+ except IncompleteRead as e: |
61 |
+ self.output.write(('\ndeeptime(): download from host %s ' |
62 |
+ 'failed for ip %s: %s\n') % (url_parts.hostname, ip, e), 2) |
63 |
+ return (None, True) |
64 |
|
65 |
signal.signal(signal.SIGALRM, signal.SIG_DFL) |