diff options
| author | Julian Andres Klode <jak@debian.org> | 2014-03-16 21:24:12 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2014-03-16 21:24:12 +0100 |
| commit | b3696b91a76226ced91e8e9de5f7d55642f1ee7a (patch) | |
| tree | a71213f7661bb0f789ef0c4101313b901aba75a0 | |
| parent | cd47e3e7e0a87ead87724d0120d408b7993e94c7 (diff) | |
| download | python-apt-b3696b91a76226ced91e8e9de5f7d55642f1ee7a.tar.gz | |
utils/get_*_mirrors*.py: Ensure failure if no mirrors were read
This ensures that we do not accidentally build a package without
a mirror list, just because the servers have some error or empty
file which we do not know about (for example, Launchpad may have
a 503, and we would not notice).
| -rwxr-xr-x | utils/get_debian_mirrors.py | 10 | ||||
| -rwxr-xr-x | utils/get_ubuntu_mirrors_from_lp.py | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/utils/get_debian_mirrors.py b/utils/get_debian_mirrors.py index c1ec3be8..4d34f5b6 100755 --- a/utils/get_debian_mirrors.py +++ b/utils/get_debian_mirrors.py @@ -17,7 +17,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +from __future__ import print_function import collections +import sys import urllib2 from debian_bundle import deb822 @@ -36,6 +38,10 @@ for mirror in deb822.Deb822.iter_paragraphs(masterlist): mirrors[country].add("%s://%s%s" % (proto, site, mirror["Archive-%s" % proto])) +if len(mirrors) == 0: + print("E: Could not read the mirror list due to some unknown issue", + file=sys.stderr) + sys.exit(1) for country in sorted(mirrors): - print "#LOC:%s" % country - print "\n".join(sorted(mirrors[country])) + print("#LOC:%s" % country) + print("\n".join(sorted(mirrors[country]))) diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index 6ff2d885..8fc34c8d 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -24,6 +24,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import sys import feedparser d = feedparser.parse("https://launchpad.net/ubuntu/+archivemirrors-rss") @@ -40,6 +41,12 @@ for entry in d.entries: keys = sorted(countries) + +if len(keys) == 0: + print("E: Could not read the mirror list due to some issue" + " -- status code: %s" % d.status, file=sys.stderr) + sys.exit(1) + print("mirror://mirrors.ubuntu.com/mirrors.txt") for country in keys: print("#LOC:%s" % country) |
