Last active
December 12, 2017 00:24
-
-
Save thurask/980e5494838653973c12f4cb141fc829 to your computer and use it in GitHub Desktop.
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
import requests | |
def get_info(platform): | |
vers = "" if platform == "linux" else "-v2" | |
testurl = "http://prerelease.keybase.io.s3.amazonaws.com/update-{0}-prod-test{1}.json".format(platform, vers) | |
regurl = "http://prerelease.keybase.io.s3.amazonaws.com/update-{0}-prod{1}.json".format(platform, vers) | |
req_test = requests.get(testurl) | |
req_reg = requests.get(regurl) | |
return req_test.json(), req_reg.json() | |
def parse_info(info): | |
version = info["version"] | |
url = info["asset"]["url"] | |
print("{0}\n{1}".format(version, url)) | |
def linux_parse_info(info): | |
rawver = info["version"] | |
basever = rawver.split("-")[0] | |
datever = rawver.split("-")[1].split("+")[0] | |
commitver = rawver.split("-")[1].split("+")[1] | |
baseurl = "https://s3.amazonaws.com/prerelease.keybase.io/linux_binaries" | |
deb32 = "{0}/deb/keybase_{1}-{2}.{3}_i386.deb".format(baseurl, basever, datever, commitver) | |
deb64 = "{0}/deb/keybase_{1}-{2}.{3}_amd64.deb".format(baseurl, basever, datever, commitver) | |
rpm32 = "{0}/rpm/keybase-{1}.{2}.{3}-1.i386.rpm".format(baseurl, basever, datever, commitver) | |
rpm64 = "{0}/rpm/keybase-{1}.{2}.{3}-1.x86_64.rpm".format(baseurl, basever, datever, commitver) | |
print(rawver) | |
for url in (deb32, deb64, rpm32, rpm64): | |
print(url) | |
def safe_parse_info(platform, info): | |
if platform == "linux": | |
linux_parse_info(info) | |
else: | |
parse_info(info) | |
def parse_both(platform, testinfo, reginfo): | |
print("~PUBLIC~") | |
safe_parse_info(platform, reginfo) | |
print("~TESTING~") | |
safe_parse_info(platform, testinfo) | |
def platform_parse(platform): | |
plat2 = "MAC" if platform == "darwin" else platform.upper() | |
print("~~~{0}~~~".format(plat2)) | |
testinfo, reginfo = get_info(platform) | |
parse_both(platform, testinfo, reginfo) | |
def main(): | |
platform_parse("windows") | |
platform_parse("darwin") | |
platform_parse("linux") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment