diff options
| author | Shawn O. Pearce <sop@google.com> | 2011-10-11 09:31:58 -0700 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2011-10-11 09:31:58 -0700 |
| commit | bf1fbb20ab33cc479881a2b755e336872971dd78 (patch) | |
| tree | 753dc46108148ffa4a579a932e599e6b85450f30 | |
| parent | 29472463ba601e9c0513eadb19470e435b2601a1 (diff) | |
| download | git-repo-bf1fbb20ab33cc479881a2b755e336872971dd78.tar.gz | |
Fix AttributeError: 'HTTPError' object has no attribute 'reason'v1.7.7.2
Not every version of urllib2 supplies a reason object on the
HTTPError exception that it throws from urlopen(). Work around
this by using str(e) instead and hope the string formatting includes
sufficient information.
Change-Id: I0f4586dba0aa7152691b2371627c951f91fdfc8d
Signed-off-by: Shawn O. Pearce <sop@google.com>
| -rw-r--r-- | git_config.py | 11 | ||||
| -rw-r--r-- | project.py | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/git_config.py b/git_config.py index bcd6e8d6..ac41d5b0 100644 --- a/git_config.py +++ b/git_config.py | |||
| @@ -26,7 +26,6 @@ import time | |||
| 26 | import urllib2 | 26 | import urllib2 |
| 27 | 27 | ||
| 28 | from signal import SIGTERM | 28 | from signal import SIGTERM |
| 29 | from urllib2 import urlopen, HTTPError | ||
| 30 | from error import GitError, UploadError | 29 | from error import GitError, UploadError |
| 31 | from trace import Trace | 30 | from trace import Trace |
| 32 | 31 | ||
| @@ -578,7 +577,7 @@ class Remote(object): | |||
| 578 | self._review_port = info[2] | 577 | self._review_port = info[2] |
| 579 | else: | 578 | else: |
| 580 | try: | 579 | try: |
| 581 | info = urlopen(u).read() | 580 | info = urllib2.urlopen(u).read() |
| 582 | if info == 'NOT_AVAILABLE': | 581 | if info == 'NOT_AVAILABLE': |
| 583 | raise UploadError('%s: SSH disabled' % self.review) | 582 | raise UploadError('%s: SSH disabled' % self.review) |
| 584 | if '<' in info: | 583 | if '<' in info: |
| @@ -590,15 +589,15 @@ class Remote(object): | |||
| 590 | self._review_protocol = 'ssh' | 589 | self._review_protocol = 'ssh' |
| 591 | self._review_host = info.split(" ")[0] | 590 | self._review_host = info.split(" ")[0] |
| 592 | self._review_port = info.split(" ")[1] | 591 | self._review_port = info.split(" ")[1] |
| 593 | except urllib2.URLError, e: | 592 | except urllib2.HTTPError, e: |
| 594 | raise UploadError('%s: %s' % (self.review, e.reason[1])) | ||
| 595 | except HTTPError, e: | ||
| 596 | if e.code == 404: | 593 | if e.code == 404: |
| 597 | self._review_protocol = 'http-post' | 594 | self._review_protocol = 'http-post' |
| 598 | self._review_host = None | 595 | self._review_host = None |
| 599 | self._review_port = None | 596 | self._review_port = None |
| 600 | else: | 597 | else: |
| 601 | raise UploadError('Upload over ssh unavailable') | 598 | raise UploadError('Upload over SSH unavailable') |
| 599 | except urllib2.URLError, e: | ||
| 600 | raise UploadError('%s: %s' % (self.review, str(e))) | ||
| 602 | 601 | ||
| 603 | REVIEW_CACHE[u] = ( | 602 | REVIEW_CACHE[u] = ( |
| 604 | self._review_protocol, | 603 | self._review_protocol, |
| @@ -1491,7 +1491,7 @@ class Project(object): | |||
| 1491 | msg = '' | 1491 | msg = '' |
| 1492 | raise DownloadError('HTTP %s%s' % (e.code, msg)) | 1492 | raise DownloadError('HTTP %s%s' % (e.code, msg)) |
| 1493 | except urllib2.URLError, e: | 1493 | except urllib2.URLError, e: |
| 1494 | raise DownloadError('%s (%s)' % (e.reason, req.get_host())) | 1494 | raise DownloadError('%s: %s ' % (req.get_host(), str(e))) |
| 1495 | 1495 | ||
| 1496 | p = None | 1496 | p = None |
| 1497 | try: | 1497 | try: |
