diff options
author | Shawn O. Pearce <sop@google.com> | 2009-08-22 18:39:49 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-08-22 18:41:16 -0700 |
commit | d2dfac81ad6a060179b4b2289060af2dc7a5cdfd (patch) | |
tree | c783e72b72e7c199ef39d036bb94ca15ec7c59ec /git_config.py | |
parent | 47199010671a6724e18f061f4da63dcd46e3f354 (diff) | |
download | git-repo-d2dfac81ad6a060179b4b2289060af2dc7a5cdfd.tar.gz |
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>
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 10 |
1 files changed, 7 insertions, 3 deletions
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 | |||
19 | import subprocess | 19 | import subprocess |
20 | import sys | 20 | import sys |
21 | import time | 21 | import time |
22 | import urllib2 | ||
23 | |||
22 | from signal import SIGTERM | 24 | from signal import SIGTERM |
23 | from urllib2 import urlopen, HTTPError | 25 | from urllib2 import urlopen, HTTPError |
24 | from error import GitError, UploadError | 26 | from error import GitError, UploadError |
@@ -487,23 +489,25 @@ class Remote(object): | |||
487 | try: | 489 | try: |
488 | info = urlopen(u).read() | 490 | info = urlopen(u).read() |
489 | if info == 'NOT_AVAILABLE': | 491 | if info == 'NOT_AVAILABLE': |
490 | raise UploadError('Upload over ssh unavailable') | 492 | raise UploadError('%s: SSH disabled' % self.review) |
491 | if '<' in info: | 493 | if '<' in info: |
492 | # Assume the server gave us some sort of HTML | 494 | # Assume the server gave us some sort of HTML |
493 | # response back, like maybe a login page. | 495 | # response back, like maybe a login page. |
494 | # | 496 | # |
495 | raise UploadError('Cannot read %s:\n%s' % (u, info)) | 497 | raise UploadError('%s: Cannot parse response' % u) |
496 | 498 | ||
497 | self._review_protocol = 'ssh' | 499 | self._review_protocol = 'ssh' |
498 | self._review_host = info.split(" ")[0] | 500 | self._review_host = info.split(" ")[0] |
499 | self._review_port = info.split(" ")[1] | 501 | self._review_port = info.split(" ")[1] |
502 | except urllib2.URLError, e: | ||
503 | raise UploadError('%s: %s' % (self.review, e.reason[1])) | ||
500 | except HTTPError, e: | 504 | except HTTPError, e: |
501 | if e.code == 404: | 505 | if e.code == 404: |
502 | self._review_protocol = 'http-post' | 506 | self._review_protocol = 'http-post' |
503 | self._review_host = None | 507 | self._review_host = None |
504 | self._review_port = None | 508 | self._review_port = None |
505 | else: | 509 | else: |
506 | raise UploadError('Cannot guess Gerrit version') | 510 | raise UploadError('Upload over ssh unavailable') |
507 | 511 | ||
508 | REVIEW_CACHE[u] = ( | 512 | REVIEW_CACHE[u] = ( |
509 | self._review_protocol, | 513 | self._review_protocol, |