-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts/get_latest_release.py: fixed bug where JSON was being imprope…
…rly accessed Signed-off-by: Bill Robinson <[email protected]>
- Loading branch information
Showing
1 changed file
with
14 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
#!/usr/local/bin/python | ||
#!/usr/bin/env python | ||
|
||
import json | ||
import requests | ||
import sys | ||
|
||
DEFAULT_VERSION = "1.0.0" | ||
|
||
HTTP_OK = 200 | ||
|
||
# Try to get the latest release version | ||
r = requests.get("https://api.github.com/repos/contiv/install/releases/latest") | ||
if r.status_code != HTTP_OK: | ||
# Get all the releases (include pre-releases) and pick the first of them | ||
r = requests.get("https://api.github.com/repos/contiv/install/releases") | ||
if r.status_code != HTTP_OK: | ||
# Return a known version | ||
print "1.0.0-beta.3" | ||
print DEFAULT_VERSION | ||
sys.exit(1) | ||
|
||
try: | ||
releases = json.loads(r.content) | ||
print releases[0]['name'] | ||
except: | ||
print DEFAULT_VERSION | ||
sys.exit(1) | ||
try: | ||
releases = json.loads(r.content) | ||
print releases[0]['name'] | ||
print releases['name'] | ||
except: | ||
print "1.0.0-beta.3" | ||
print DEFAULT_VERSION | ||
sys.exit(1) |