From: Zhang Qiang Date: Fri, 12 Oct 2012 00:46:16 +0000 (+0800) Subject: More correct way to parse repo url X-Git-Tag: 0.11~27^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e4814fffebac500ac6ba3a64a47c701c013d323;p=tools%2Fgbs.git More correct way to parse repo url Only continue with PageNotFound exception, other exceptions, such as AuthFailed, TimeoutError, UrlError, raise exception and exit directly. Change-Id: I5f98d632f3af88223c266dba1a35e253c7767b1c --- diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index 3c6898d..57e1fbe 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -144,19 +144,9 @@ class TempCopy(object): os.unlink(self.name) -class AuthFailed(errors.UrlError): - 'authenticated or authorization failed: 401, 403' - class PageNotFound(errors.UrlError): 'page not found error: 404' -class CallbackAborted(errors.UrlError): - 'break when fetching url' - -class TimeoutError(errors.UrlError): - 'timeout when fetching url' - - class URLGrabber(object): '''grab an url and save to local file''' @@ -213,15 +203,18 @@ class URLGrabber(object): http_code = curl.getinfo(pycurl.HTTP_CODE) if errcode == pycurl.E_OPERATION_TIMEOUTED: - raise TimeoutError(err) + raise errors.UrlError("connect timeout to %s, maybe it's " + "caused by proxy settings, please " + "check." % curl.url) elif errcode == pycurl.E_ABORTED_BY_CALLBACK: - raise CallbackAborted(err) + raise KeyboardInterrupt(err) elif http_code in (401, 403): - raise AuthFailed(err) + raise errors.UrlError('authenticate failed on: %s' % curl.url) elif http_code == 404: raise PageNotFound(err) else: - raise errors.UrlError('URL error %s: "%s"' % (errcode, errmsg)) + raise errors.UrlError('URL error on %s: (%s: "%s")' % + (curl.url, errcode, errmsg)) finally: signal.signal(signal.SIGINT, original_handler) @@ -360,6 +353,8 @@ class RepoParser(object): return latest_repo_url = repo.pathjoin('../../../../') + if latest_repo_url.find('../') >= 0: + return meta = self._fetch_build_meta(latest_repo_url) if meta: self._fetch_build_conf(latest_repo_url, meta) @@ -373,15 +368,7 @@ class RepoParser(object): self._fetch_build_conf(repo, meta) for repo in remotes: - try: - deal_with_one_repo(repo) - except AuthFailed, err: - msger.warning('authenticate failed, ignore %s' % repo) - except TimeoutError, err: - msger.warning("connect timeout to %s, maybe it's caused " - "by proxy settings, please check." % repo) - except CallbackAborted, err: - raise KeyboardInterrupt(err) + deal_with_one_repo(repo) @staticmethod def split_out_local_repo(repos):