11# Copyright (C) 2021 Intel Corporation
22# SPDX-License-Identifier: GPL-3.0-or-later
33
4- import json
54import textwrap
6- from urllib import request
75
6+ import requests
87from packaging import version
98
109from cve_bin_tool .log import LOGGER
@@ -18,19 +17,18 @@ def check_latest_version():
1817 name : str = "cve-bin-tool"
1918 url : str = f"https://pypi.org/pypi/{ name } /json"
2019 try :
21- with request .urlopen (url ) as resp : # nosec - static url above
22- package_json = json .load (resp )
23- pypi_version = package_json ["info" ]["version" ]
24- if pypi_version != VERSION :
20+ package_json = requests .get (url ).json ()
21+ pypi_version = package_json ["info" ]["version" ]
22+ if pypi_version != VERSION :
23+ LOGGER .info (
24+ f"[bold red]You are running version { VERSION } of { name } but the latest PyPI Version is { pypi_version } .[/]" ,
25+ extra = {"markup" : True },
26+ )
27+ if version .parse (VERSION ) < version .parse (pypi_version ):
2528 LOGGER .info (
26- f "[bold red]You are running version { VERSION } of { name } but the latest PyPI Version is { pypi_version } .[/]" ,
29+ "[bold yellow]Alert: We recommend using the latest stable release .[/]" ,
2730 extra = {"markup" : True },
2831 )
29- if version .parse (VERSION ) < version .parse (pypi_version ):
30- LOGGER .info (
31- "[bold yellow]Alert: We recommend using the latest stable release.[/]" ,
32- extra = {"markup" : True },
33- )
3432 except Exception as error :
3533 LOGGER .warning (
3634 textwrap .dedent (
0 commit comments