1
0
Fork 0
mirror of https://gitlab.wikimedia.org/ladsgroup/Phabricator-maintenance-bot synced 2024-11-22 03:52:37 +01:00

Merge pull request #15 from urbanecm/get-file-from-gerrit-404

new_wikis_handler: Make get_file_from_gerrit support 404s
This commit is contained in:
Amir Sarabadani 2020-07-14 16:49:09 +02:00 committed by GitHub
commit 388766bfef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):