Skip to content

Commit

Permalink
scripts/get_latest_release.py: fixed bug where JSON was being imprope…
Browse files Browse the repository at this point in the history
…rly accessed

Signed-off-by: Bill Robinson <[email protected]>
  • Loading branch information
dseevr committed Jun 17, 2017
1 parent af73ae1 commit c04b843
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions scripts/get_latest_release.py
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)

0 comments on commit c04b843

Please sign in to comment.