aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2014-05-04 19:03:01 -0700
committerBrian Dolbec <dolsen@gentoo.org>2014-05-04 19:03:01 -0700
commit3445069b3da6a33356f2d16a9ff27a722873512d (patch)
tree960b1f35cda762a32f6c2c38cf30be98d817fe5a
parentUpdate man page with new options (diff)
downloadmirrorselect-2.2.1.tar.gz
mirrorselect-2.2.1.tar.bz2
mirrorselect-2.2.1.zip
selectors.py: Add IncompleteRead exception2.2.1
Improve output formatting.
-rw-r--r--mirrorselect/selectors.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py
index 5d30695..1aa5f11 100644
--- a/mirrorselect/selectors.py
+++ b/mirrorselect/selectors.py
@@ -42,6 +42,8 @@ if sys.version_info[0] >= 3:
url_unparse = urllib.parse.urlunparse
url_open = urllib.request.urlopen
HTTPError = urllib.error.HTTPError
+ import http.client
+ IncompleteRead = http.client.IncompleteRead
else:
import urllib2
import urlparse
@@ -49,6 +51,8 @@ else:
url_unparse = urlparse.urlunparse
url_open = urllib2.urlopen
HTTPError = urllib2.HTTPError
+ import httplib
+ IncompleteRead = httplib.IncompleteRead
from mirrorselect.output import encoder, get_encoding, decode_selection
@@ -369,7 +373,7 @@ class Deep(object):
f.close()
if md5 != self.test_md5:
self.output.write(
- "deeptime(): md5sum error for file: %s\n"
+ "\ndeeptime(): md5sum error for file: %s\n"
% self.test_file +
" expected: %s\n" % self.test_md5 +
" got.....: %s\n" % md5 +
@@ -382,13 +386,17 @@ class Deep(object):
signal.alarm(0)
except EnvironmentError as e:
- self.output.write(('deeptime(): download from host %s '
+ self.output.write(('\ndeeptime(): download from host %s '
'failed for ip %s: %s\n') % (url_parts.hostname, ip, e), 2)
return (None, True)
except TimeoutException:
- self.output.write(('deeptime(): download from host %s '
+ self.output.write(('\ndeeptime(): download from host %s '
'timed out for ip %s\n') % (url_parts.hostname, ip), 2)
return (None, True)
+ except IncompleteRead as e:
+ self.output.write(('\ndeeptime(): download from host %s '
+ 'failed for ip %s: %s\n') % (url_parts.hostname, ip, e), 2)
+ return (None, True)
signal.signal(signal.SIGALRM, signal.SIG_DFL)