diff options
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/git_config.py b/git_config.py index 26fc970b..ff815e35 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -23,6 +23,8 @@ try: | |||
23 | except ImportError: | 23 | except ImportError: |
24 | import dummy_threading as _threading | 24 | import dummy_threading as _threading |
25 | import time | 25 | import time |
26 | import urllib2 | ||
27 | |||
26 | from signal import SIGTERM | 28 | from signal import SIGTERM |
27 | from urllib2 import urlopen, HTTPError | 29 | from urllib2 import urlopen, HTTPError |
28 | from error import GitError, UploadError | 30 | from error import GitError, UploadError |
@@ -78,6 +80,14 @@ class GitConfig(object): | |||
78 | else: | 80 | else: |
79 | self._pickle = pickleFile | 81 | self._pickle = pickleFile |
80 | 82 | ||
83 | def ClearCache(self): | ||
84 | if os.path.exists(self._pickle): | ||
85 | os.remove(self._pickle) | ||
86 | self._cache_dict = None | ||
87 | self._section_dict = None | ||
88 | self._remotes = {} | ||
89 | self._branches = {} | ||
90 | |||
81 | def Has(self, name, include_defaults = True): | 91 | def Has(self, name, include_defaults = True): |
82 | """Return true if this configuration file has the key. | 92 | """Return true if this configuration file has the key. |
83 | """ | 93 | """ |
@@ -563,23 +573,25 @@ class Remote(object): | |||
563 | try: | 573 | try: |
564 | info = urlopen(u).read() | 574 | info = urlopen(u).read() |
565 | if info == 'NOT_AVAILABLE': | 575 | if info == 'NOT_AVAILABLE': |
566 | raise UploadError('Upload over ssh unavailable') | 576 | raise UploadError('%s: SSH disabled' % self.review) |
567 | if '<' in info: | 577 | if '<' in info: |
568 | # Assume the server gave us some sort of HTML | 578 | # Assume the server gave us some sort of HTML |
569 | # response back, like maybe a login page. | 579 | # response back, like maybe a login page. |
570 | # | 580 | # |
571 | raise UploadError('Cannot read %s:\n%s' % (u, info)) | 581 | raise UploadError('%s: Cannot parse response' % u) |
572 | 582 | ||
573 | self._review_protocol = 'ssh' | 583 | self._review_protocol = 'ssh' |
574 | self._review_host = info.split(" ")[0] | 584 | self._review_host = info.split(" ")[0] |
575 | self._review_port = info.split(" ")[1] | 585 | self._review_port = info.split(" ")[1] |
586 | except urllib2.URLError, e: | ||
587 | raise UploadError('%s: %s' % (self.review, e.reason[1])) | ||
576 | except HTTPError, e: | 588 | except HTTPError, e: |
577 | if e.code == 404: | 589 | if e.code == 404: |
578 | self._review_protocol = 'http-post' | 590 | self._review_protocol = 'http-post' |
579 | self._review_host = None | 591 | self._review_host = None |
580 | self._review_port = None | 592 | self._review_port = None |
581 | else: | 593 | else: |
582 | raise UploadError('Cannot guess Gerrit version') | 594 | raise UploadError('Upload over ssh unavailable') |
583 | 595 | ||
584 | REVIEW_CACHE[u] = ( | 596 | REVIEW_CACHE[u] = ( |
585 | self._review_protocol, | 597 | self._review_protocol, |