Simplify Python script (#71)

This commit is contained in:
Bas Nijholt 2021-01-04 20:27:29 +01:00 committed by GitHub
parent 00352c8c4e
commit b49feaa906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,21 +84,18 @@ msg "Getting URL for latest Home Assistant disk image..."
RELEASE_EXT=vmdk.gz RELEASE_EXT=vmdk.gz
URL=$(cat<<EOF | python3 URL=$(cat<<EOF | python3
import requests import requests
url = 'https://api.github.com/repos/home-assistant/operating-system/releases' url = "https://api.github.com/repos/home-assistant/operating-system/releases"
r = requests.get(url).json() r = requests.get(url).json()
if 'message' in r: if "message" in r:
exit() exit()
for release in r: for release in r:
if release['prerelease']: if release["prerelease"]:
continue continue
for asset in release['assets']: for asset in release["assets"]:
if asset['name'].endswith('$RELEASE_EXT'): if asset["name"].endswith("$RELEASE_EXT"):
global image_url image_url = asset["browser_download_url"]
image_url = asset['browser_download_url'] print(image_url)
break exit()
if 'image_url' in globals():
print(image_url)
break
EOF EOF
) )
if [ -z "$URL" ]; then if [ -z "$URL" ]; then