Fix ZFS feature generation script

This was breaking on FreeBSD, as some of the URLs were returning 404.  That
raises an HTTPError.  If we catch those and skip those sources (just as we
were already doing for HTTP codes other than 200), the script completes.  But
then we get a whole bunch of columns full of "no", which does not seem useful.
I added code to skip columns for sources that failed to download.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
This commit is contained in:
Richard Laager
2021-01-31 18:00:49 -06:00
parent fac3cb834b
commit d08af47f7a

View File

@@ -8,6 +8,7 @@ import logging
import sys import sys
from collections import defaultdict from collections import defaultdict
from urllib.error import HTTPError
from urllib.request import urlopen from urllib.request import urlopen
from datetime import datetime from datetime import datetime
from re import sub as regex, findall from re import sub as regex, findall
@@ -160,13 +161,20 @@ features = defaultdict(list)
readonly = dict() readonly = dict()
for name, sub in sources.items(): for name, sub in sources.items():
found = {}
LOG.debug('Work on %s...', name) LOG.debug('Work on %s...', name)
for ver, url in sub.items(): for ver, url in sub.items():
LOG.debug('Get %s...', url) LOG.debug('Get %s...', url)
with urlopen(url) as c: try:
if c.getcode() != 200: with urlopen(url) as c:
continue if c.getcode() != 200:
man = c.read().decode('utf-8') LOG.debug('Failed with HTTP code %d', c.getcode())
continue
man = c.read().decode('utf-8')
except HTTPError:
LOG.debug('Failed with HTTPError')
continue
found[ver] = url
for line in man.split('\n'): for line in man.split('\n'):
if line.startswith('.It '): if line.startswith('.It '):
line = line[4:] line = line[4:]
@@ -191,6 +199,7 @@ for name, sub in sources.items():
# https://github.com/Nexenta/illumos-nexenta/blob/release-4.0.4-FP/usr/src/common/zfs/zfeature_common.c # https://github.com/Nexenta/illumos-nexenta/blob/release-4.0.4-FP/usr/src/common/zfs/zfeature_common.c
if name == 'Nexenta' and ver.startswith('4.'): if name == 'Nexenta' and ver.startswith('4.'):
features[('meta_devices', 'com.nexenta')].append((name, ver)) features[('meta_devices', 'com.nexenta')].append((name, ver))
sources[name] = found
os_sources = sources.copy() os_sources = sources.copy()
os_sources.pop(openzfs_key) os_sources.pop(openzfs_key)