jenkins-bot has submitted this change and it was merged. 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, 39 insertions(+), 26 deletions(-) Approvals: Dachary: Looks good to me, approved jenkins-bot: Verified diff --git a/FLOSSbot/repository.py b/FLOSSbot/repository.py index 923cad0..9cedd79 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: + return False def verify_protocol(self, url, protocol, credentials): if protocol == self.Q_git: @@ -458,32 +461,42 @@ 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: merged Gerrit-Change-Id: I07521a659ed604475e3794b81eda3c69f52453a2 Gerrit-PatchSet: 2 Gerrit-Project: pywikibot/bots/FLOSSbot Gerrit-Branch: master Gerrit-Owner: Dachary <l...@dachary.org> Gerrit-Reviewer: Dachary <l...@dachary.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits