mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
upload: Catch and cleanly report connectivity errors
Instead of giving a Python backtrace when there is a connectivity
problem during repo upload, report that we cannot access the host,
and why, with a halfway decent error message.
Bug: REPO-45
Change-Id: I9a45b387e86e48073a2d99bd6d594c1a7d6d99d4
Signed-off-by: Shawn O. Pearce <sop@google.com>
(cherry picked from commit d2dfac81ad
)
This commit is contained in:
parent
1b5a4a0c5d
commit
f00e0ce556
@ -23,6 +23,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import dummy_threading as _threading
|
import dummy_threading as _threading
|
||||||
import time
|
import time
|
||||||
|
import urllib2
|
||||||
|
|
||||||
from signal import SIGTERM
|
from signal import SIGTERM
|
||||||
from urllib2 import urlopen, HTTPError
|
from urllib2 import urlopen, HTTPError
|
||||||
from error import GitError, UploadError
|
from error import GitError, UploadError
|
||||||
@ -563,23 +565,25 @@ class Remote(object):
|
|||||||
try:
|
try:
|
||||||
info = urlopen(u).read()
|
info = urlopen(u).read()
|
||||||
if info == 'NOT_AVAILABLE':
|
if info == 'NOT_AVAILABLE':
|
||||||
raise UploadError('Upload over ssh unavailable')
|
raise UploadError('%s: SSH disabled' % self.review)
|
||||||
if '<' in info:
|
if '<' in info:
|
||||||
# Assume the server gave us some sort of HTML
|
# Assume the server gave us some sort of HTML
|
||||||
# response back, like maybe a login page.
|
# response back, like maybe a login page.
|
||||||
#
|
#
|
||||||
raise UploadError('Cannot read %s:\n%s' % (u, info))
|
raise UploadError('%s: Cannot parse response' % u)
|
||||||
|
|
||||||
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:
|
||||||
|
raise UploadError('%s: %s' % (self.review, e.reason[1]))
|
||||||
except HTTPError, e:
|
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('Cannot guess Gerrit version')
|
raise UploadError('Upload over ssh unavailable')
|
||||||
|
|
||||||
REVIEW_CACHE[u] = (
|
REVIEW_CACHE[u] = (
|
||||||
self._review_protocol,
|
self._review_protocol,
|
||||||
|
@ -283,15 +283,19 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
have_errors = True
|
have_errors = True
|
||||||
|
|
||||||
print >>sys.stderr, ''
|
print >>sys.stderr, ''
|
||||||
print >>sys.stderr, '--------------------------------------------'
|
print >>sys.stderr, '----------------------------------------------------------------------'
|
||||||
|
|
||||||
if have_errors:
|
if have_errors:
|
||||||
for branch in todo:
|
for branch in todo:
|
||||||
if not branch.uploaded:
|
if not branch.uploaded:
|
||||||
print >>sys.stderr, '[FAILED] %-15s %-15s (%s)' % (
|
if len(str(branch.error)) <= 30:
|
||||||
|
fmt = ' (%s)'
|
||||||
|
else:
|
||||||
|
fmt = '\n (%s)'
|
||||||
|
print >>sys.stderr, ('[FAILED] %-15s %-15s' + fmt) % (
|
||||||
branch.project.relpath + '/', \
|
branch.project.relpath + '/', \
|
||||||
branch.name, \
|
branch.name, \
|
||||||
branch.error)
|
str(branch.error))
|
||||||
print >>sys.stderr, ''
|
print >>sys.stderr, ''
|
||||||
|
|
||||||
for branch in todo:
|
for branch in todo:
|
||||||
|
Loading…
Reference in New Issue
Block a user