diff options
author | Akira TAGOH <akira@tagoh.org> | 2017-08-25 11:46:53 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2017-08-25 11:47:09 +0900 |
commit | 92da67a9fcf9fa48ebb40f2032d47291d5427d41 (patch) | |
tree | 865d22dcca0cdaa9103c43145e9e78941144f536 | |
parent | 12cf4c17db76bf4e30c0f94f301ac5b3be7e070c (diff) |
fc-blanks: fall back to the static data available in repo if downloaded data is corrupted
https://bugs.freedesktop.org/show_bug.cgi?id=102399
-rwxr-xr-x | fc-blanks/fc-blanks.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fc-blanks/fc-blanks.py b/fc-blanks/fc-blanks.py index cc23cde2..410178a6 100755 --- a/fc-blanks/fc-blanks.py +++ b/fc-blanks/fc-blanks.py @@ -19,10 +19,14 @@ try: fp = urlopen('http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3AGC%3DZs%3A][%3ADI%3A]&abb=on&ucd=on&esc=on&g') data = fp.read() fp.close() + # check before writing if data isn't corrupted. + dom = html.fromstring(data) + x = dom.xpath('/html/body/form/p/text()') + p = x[1] fp = open(datafile, 'wb'); fp.write(data); fp.close(); -except URLError: +except (URLError, IndexError): # fall back reading the static data in repo try: fp = open(datafile) |