Skip to content

Commit

Permalink
Handle errors from repology API slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-turney committed Jul 11, 2024
1 parent 90325bb commit 8653d5f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion calm/repology.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import json
import logging
import time
import urllib.error
import urllib.request
from collections import namedtuple

Expand Down Expand Up @@ -62,7 +63,15 @@ def repology_fetch_versions():
url = url + last_pn + '/'
url += '?inrepo=cygwin'

r = urllib.request.urlopen(url)
request = urllib.request.Request(url)
request.add_header('User-Agent', 'CygwinUpstreamVersionFetch/1.0 +http://cygwin.com/')

try:
r = urllib.request.urlopen(request)
except urllib.error.URLError as e:
logging.error("consulting repology for upstream versions failed: %s" % (e.reason))
return {}

j = json.loads(r.read().decode('utf-8'))

for pn in sorted(j.keys()):
Expand Down

0 comments on commit 8653d5f

Please sign in to comment.