allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] git commit: [#7124] handle connection errors as well, when validation Trac URL
Date Fri, 07 Feb 2014 16:12:31 GMT
[#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 <dbrondsema@slashdotmedia.com>
Authored: Fri Feb 7 16:09:51 2014 +0000
Committer: Dave Brondsema <dbrondsema@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)


Mime
View raw message