in azext_edge/edge/util/version_check.py [0:0]
def get_latest_from_github(url: str = GH_CLI_CONSTANTS_ENDPOINT, timeout: int = 10) -> Optional[str]:
try:
response = requests.get(url, timeout=timeout)
if response.status_code != 200:
logger.debug(
"Failed to fetch the latest version from '%s' with status code '%s' and reason '%s'",
url,
response.status_code,
response.reason,
)
return None
for line in response.iter_lines():
txt = line.decode("utf-8", errors="ignore")
if txt.startswith("VERSION"):
match = re.search(r"VERSION = \"(.*)\"$", txt)
if match:
return match.group(1)
except Exception as ex:
logger.info("Failed to get the latest version from '%s'. %s", url, str(ex))