You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/02/07 17:12:31 UTC
[2/2] git commit: [#7124] handle connection errors as well,
when validation Trac URL
[#7124] handle connection errors as well, when validation Trac URL
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/07e206f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/07e206f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/07e206f1
Branch: refs/heads/master
Commit: 07e206f1b8de26b350e5228ca7752a750b630b08
Parents: 1da8300
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Feb 7 16:09:51 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Feb 7 16:09:51 2014 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/trac/__init__.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/07e206f1/ForgeImporters/forgeimporters/trac/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/__init__.py b/ForgeImporters/forgeimporters/trac/__init__.py
index c861469..a1fbceb 100644
--- a/ForgeImporters/forgeimporters/trac/__init__.py
+++ b/ForgeImporters/forgeimporters/trac/__init__.py
@@ -38,7 +38,12 @@ class TracURLValidator(fev.URL):
# normalize trailing slash
value = value.rstrip('/') + '/'
- resp = requests.head(value, allow_redirects=True)
- if resp.status_code != 200:
- raise fev.Invalid(self.message('unavailable', state), value, state)
- return value
+ try:
+ resp = requests.head(value, allow_redirects=True)
+ except IOError:
+ # fall through to 'raise' below
+ pass
+ else:
+ if resp.status_code == 200:
+ return value
+ raise fev.Invalid(self.message('unavailable', state), value, state)