mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Fix AttributeError: 'HTTPError' object has no attribute 'reason'
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>
This commit is contained in:
parent
29472463ba
commit
bf1fbb20ab
@ -26,7 +26,6 @@ import time
|
|||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from signal import SIGTERM
|
from signal import SIGTERM
|
||||||
from urllib2 import urlopen, HTTPError
|
|
||||||
from error import GitError, UploadError
|
from error import GitError, UploadError
|
||||||
from trace import Trace
|
from trace import Trace
|
||||||
|
|
||||||
@ -578,7 +577,7 @@ class Remote(object):
|
|||||||
self._review_port = info[2]
|
self._review_port = info[2]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
info = urlopen(u).read()
|
info = urllib2.urlopen(u).read()
|
||||||
if info == 'NOT_AVAILABLE':
|
if info == 'NOT_AVAILABLE':
|
||||||
raise UploadError('%s: SSH disabled' % self.review)
|
raise UploadError('%s: SSH disabled' % self.review)
|
||||||
if '<' in info:
|
if '<' in info:
|
||||||
@ -590,15 +589,15 @@ class Remote(object):
|
|||||||
self._review_protocol = 'ssh'
|
self._review_protocol = 'ssh'
|
||||||
self._review_host = info.split(" ")[0]
|
self._review_host = info.split(" ")[0]
|
||||||
self._review_port = info.split(" ")[1]
|
self._review_port = info.split(" ")[1]
|
||||||
except urllib2.URLError, e:
|
except urllib2.HTTPError, e:
|
||||||
raise UploadError('%s: %s' % (self.review, e.reason[1]))
|
|
||||||
except HTTPError, e:
|
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
self._review_protocol = 'http-post'
|
self._review_protocol = 'http-post'
|
||||||
self._review_host = None
|
self._review_host = None
|
||||||
self._review_port = None
|
self._review_port = None
|
||||||
else:
|
else:
|
||||||
raise UploadError('Upload over ssh unavailable')
|
raise UploadError('Upload over SSH unavailable')
|
||||||
|
except urllib2.URLError, e:
|
||||||
|
raise UploadError('%s: %s' % (self.review, str(e)))
|
||||||
|
|
||||||
REVIEW_CACHE[u] = (
|
REVIEW_CACHE[u] = (
|
||||||
self._review_protocol,
|
self._review_protocol,
|
||||||
|
@ -1491,7 +1491,7 @@ class Project(object):
|
|||||||
msg = ''
|
msg = ''
|
||||||
raise DownloadError('HTTP %s%s' % (e.code, msg))
|
raise DownloadError('HTTP %s%s' % (e.code, msg))
|
||||||
except urllib2.URLError, e:
|
except urllib2.URLError, e:
|
||||||
raise DownloadError('%s (%s)' % (e.reason, req.get_host()))
|
raise DownloadError('%s: %s ' % (req.get_host(), str(e)))
|
||||||
|
|
||||||
p = None
|
p = None
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user