diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2019-01-14 13:01:01 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2019-01-14 13:01:01 +0100 |
commit | 099d86e68c0db0987bdb954d40a6fed7d65f88f2 (patch) | |
tree | ce42d51701edaf6208349c81ce3d10a0f767988b /scripts | |
parent | 515cef87a1b676ad09b1fc2243815ffe3310b221 (diff) |
added get script
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/gh-list.py | 3 | ||||
-rw-r--r-- | scripts/gh.py | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/scripts/gh-list.py b/scripts/gh-list.py index f8b1c91..a2e7955 100644 --- a/scripts/gh-list.py +++ b/scripts/gh-list.py @@ -8,5 +8,4 @@ tok = os.getenv('GITHUB_TOKEN') draft = [r for r in gh('releases') if r['draft']][0] for a in draft['assets']: - print(a['browser_download_url'] + - '?access_token=' + tok) + print(a['browser_download_url']) diff --git a/scripts/gh.py b/scripts/gh.py index 13a8880..d12b416 100644 --- a/scripts/gh.py +++ b/scripts/gh.py @@ -13,15 +13,18 @@ if tok == '': def pr(j): print(json.dumps(j, indent=2)) # call GitHub API with curl -def gh(s, args=[]): - cmd = (["curl", "-s"] + args + +def gh(s, args=[], quiet=True, parse=True): + cmd = (["curl"] + + (["-s"] if quiet else []) + + args + ["-H", "Authorization: token " + tok] + [s if 'https://' in s else api_url + '/' + s]) # ONLY UN-COMMENT FOR TESTING: # print(' '.join(cmd)) p = Popen(cmd, stdout=PIPE) resp = p.stdout.read() - return json.loads(resp if resp else '{}') + if parse: return json.loads(resp if resp else '{}') + else: return resp def get_release(n): rs = [r for r in gh('releases') if r['name'] == n] |