From eda3c0632a4ba95e4350a4c3951ff3f6865ae0f5 Mon Sep 17 00:00:00 2001 From: Martin Urbanec Date: Tue, 14 Jul 2020 14:43:18 +0000 Subject: [PATCH] new_wikis_handler: Make get_file_from_gerrit support 404s Previously, the function threw fatal on a 404. --- new_wikis_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/new_wikis_handler.py b/new_wikis_handler.py index 95dec14..797012e 100644 --- a/new_wikis_handler.py +++ b/new_wikis_handler.py @@ -20,7 +20,11 @@ def add_text(a): def get_file_from_gerrit(path): gerrit_url = 'https://gerrit.wikimedia.org/g/' url = gerrit_url + '{0}?format=TEXT'.format(path) - return base64.b64decode(requests.get(url).text).decode('utf-8') + r = requests.get(url) + if r.status_code == 200: + return base64.b64decode(r.text).decode('utf-8') + else: + return '' def hostname_resolves(hostname):