diff --git a/git_config.py b/git_config.py index 9dba699a..b6288219 100644 --- a/git_config.py +++ b/git_config.py @@ -19,6 +19,8 @@ import re import subprocess import sys import time +import urllib2 + from signal import SIGTERM from urllib2 import urlopen, HTTPError from error import GitError, UploadError @@ -487,23 +489,25 @@ class Remote(object): try: info = urlopen(u).read() if info == 'NOT_AVAILABLE': - raise UploadError('Upload over ssh unavailable') + raise UploadError('%s: SSH disabled' % self.review) if '<' in info: # Assume the server gave us some sort of HTML # 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_host = info.split(" ")[0] self._review_port = info.split(" ")[1] + except urllib2.URLError, e: + raise UploadError('%s: %s' % (self.review, e.reason[1])) except HTTPError, e: if e.code == 404: self._review_protocol = 'http-post' self._review_host = None self._review_port = None else: - raise UploadError('Cannot guess Gerrit version') + raise UploadError('Upload over ssh unavailable') REVIEW_CACHE[u] = ( self._review_protocol, diff --git a/subcmds/upload.py b/subcmds/upload.py index 8e3d2723..2ab6a484 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py @@ -273,15 +273,19 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ have_errors = True print >>sys.stderr, '' - print >>sys.stderr, '--------------------------------------------' + print >>sys.stderr, '----------------------------------------------------------------------' if have_errors: for branch in todo: 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.name, \ - branch.error) + str(branch.error)) print >>sys.stderr, '' for branch in todo: