diff options
Diffstat (limited to '.github/scripts/platform-impending-eol.py')
-rwxr-xr-x | .github/scripts/platform-impending-eol.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/.github/scripts/platform-impending-eol.py b/.github/scripts/platform-impending-eol.py index 8b0e7624b4..c57e5edde7 100755 --- a/.github/scripts/platform-impending-eol.py +++ b/.github/scripts/platform-impending-eol.py @@ -22,17 +22,27 @@ EXIT_IMPENDING = 1 EXIT_NO_DATA = 2 EXIT_FAILURE = 3 -with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response: - match response.status: - case 200: - data = json.load(response) +try: + with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response: + match response.status: + case 200: + data = json.load(response) + case _: + print( + f'Failed to retrieve data for { DISTRO } { RELEASE } ' + + f'(status: { response.status }).', + file=sys.stderr + ) + sys.exit(EXIT_FAILURE) +except urllib.error.HTTPError as e: + match e.code: case 404: print(f'No data available for { DISTRO } { RELEASE }.', file=sys.stderr) sys.exit(EXIT_NO_DATA) case _: print( f'Failed to retrieve data for { DISTRO } { RELEASE } ' + - f'(status: { response.status }).', + f'(status: { e.code }).', file=sys.stderr ) sys.exit(EXIT_FAILURE) |