Dachary has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311346

Change subject: repository: make cnx failures equivalent to 404
......................................................................

repository: make cnx failures equivalent to 404

Change-Id: I07521a659ed604475e3794b81eda3c69f52453a2
Signed-off-by: Loic Dachary <l...@dachary.org>
---
M FLOSSbot/repository.py
1 file changed, 38 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/bots/FLOSSbot 
refs/changes/46/311346/1

diff --git a/FLOSSbot/repository.py b/FLOSSbot/repository.py
index 923cad0..c474080 100644
--- a/FLOSSbot/repository.py
+++ b/FLOSSbot/repository.py
@@ -369,8 +369,11 @@
         """.format(url=url))
 
     def verify_http(self, url):
-        r = requests.head(url, allow_redirects=True)
-        return r.status_code == requests.codes.ok
+        try:
+            r = requests.head(url, allow_redirects=True)
+            return r.status_code == requests.codes.ok
+        except e:
+            return False
 
     def verify_protocol(self, url, protocol, credentials):
         if protocol == self.Q_git:
@@ -458,32 +461,41 @@
             return "svn://svn.gna.org/svn/" + m.group(1)
         if re.match('https?://sourceforge.net/p/'
                     '.*/(git|code|code-git)/ci/(default|master)/tree/', url):
-            r = requests.get(url)
-            if r.status_code != requests.codes.ok:
-                return None
-            u = re.findall('git clone (git://git.code.sf.net/p/.*/'
-                           '(?:git|code(?:-git)?))', r.text)
-            if len(u) == 1:
-                return u[0]
-            u = re.findall('hg clone (http://hg.code.sf.net/p/.*/code)',
-                           r.text)
-            if len(u) >= 1:
-                return u[0]
+            try:
+                r = requests.get(url)
+                if r.status_code != requests.codes.ok:
+                    return None
+                u = re.findall('git clone (git://git.code.sf.net/p/.*/'
+                               '(?:git|code(?:-git)?))', r.text)
+                if len(u) == 1:
+                    return u[0]
+                u = re.findall('hg clone (http://hg.code.sf.net/p/.*/code)',
+                               r.text)
+                if len(u) >= 1:
+                    return u[0]
+            except requests.ConnectionError as e:
+                pass
         if re.match('https?://sourceforge.net/p/'
                     '.*?/.*?/ci/(default|master)/tree/', url):
-            r = requests.get(url)
-            if r.status_code != requests.codes.ok:
-                return None
-            u = re.findall('hg clone (http://hg.code.sf.net/p/.*?) ', r.text)
-            if len(u) >= 1:
-                return u[0]
+            try:
+                r = requests.get(url)
+                if r.status_code != requests.codes.ok:
+                    return None
+                u = re.findall('hg clone (http://hg.code.sf.net/p/.*?) ', 
r.text)
+                if len(u) >= 1:
+                    return u[0]
+            except requests.ConnectionError as e:
+                pass
         if re.match('https?://sourceforge.net/p/'
                     '.*/(svn|code|code-0)/HEAD/tree/', url):
-            r = requests.get(url)
-            if r.status_code != requests.codes.ok:
-                return None
-            u = re.findall('svn checkout (svn://svn.code.sf.net.*/trunk)',
-                           r.text)
-            if len(u) == 1:
-                return u[0]
+            try:
+                r = requests.get(url)
+                if r.status_code != requests.codes.ok:
+                    return None
+                u = re.findall('svn checkout (svn://svn.code.sf.net.*/trunk)',
+                               r.text)
+                if len(u) == 1:
+                    return u[0]
+            except requests.ConnectionError as e:
+                pass
         return None

-- 
To view, visit https://gerrit.wikimedia.org/r/311346
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I07521a659ed604475e3794b81eda3c69f52453a2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/bots/FLOSSbot
Gerrit-Branch: master
Gerrit-Owner: Dachary <l...@dachary.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to