Spaces:
Sleeping
Sleeping
Nicky Nicolson
commited on
Commit
·
2734782
1
Parent(s):
3e49a42
read token from file
Browse files- downloadartifact.py +6 -3
downloadartifact.py
CHANGED
@@ -8,7 +8,10 @@ def getArtifactUrl(runUrl):
|
|
8 |
artifactUrl = r.json()['artifacts'][0]["archive_download_url"]
|
9 |
return artifactUrl
|
10 |
|
11 |
-
def getArtifact(artifactUrl,
|
|
|
|
|
|
|
12 |
headers = {'Authorization': 'Bearer: {}'.format(gh_token)}
|
13 |
r = requests.get(artifactUrl, headers=headers)
|
14 |
if r.status_code == 200:
|
@@ -20,13 +23,13 @@ def getArtifact(artifactUrl, gh_token, outputfile):
|
|
20 |
def main():
|
21 |
parser = argparse.ArgumentParser(description='Download artifact from github')
|
22 |
parser.add_argument('url', help='url for the artifact building run')
|
23 |
-
parser.add_argument('
|
24 |
parser.add_argument('outputfile', help='where to store downloaded file')
|
25 |
|
26 |
args = parser.parse_args()
|
27 |
artifact_url = getArtifactUrl(args.url)
|
28 |
print(artifact_url)
|
29 |
-
getArtifact(
|
30 |
|
31 |
if __name__ == '__main__':
|
32 |
main()
|
|
|
8 |
artifactUrl = r.json()['artifacts'][0]["archive_download_url"]
|
9 |
return artifactUrl
|
10 |
|
11 |
+
def getArtifact(artifactUrl, gh_tokenfile, outputfile):
|
12 |
+
gh_token = None
|
13 |
+
with open(gh_tokenfile, 'r') as f:
|
14 |
+
gh_token = f.read()
|
15 |
headers = {'Authorization': 'Bearer: {}'.format(gh_token)}
|
16 |
r = requests.get(artifactUrl, headers=headers)
|
17 |
if r.status_code == 200:
|
|
|
23 |
def main():
|
24 |
parser = argparse.ArgumentParser(description='Download artifact from github')
|
25 |
parser.add_argument('url', help='url for the artifact building run')
|
26 |
+
parser.add_argument('gh_tokenfile', help='authentication token')
|
27 |
parser.add_argument('outputfile', help='where to store downloaded file')
|
28 |
|
29 |
args = parser.parse_args()
|
30 |
artifact_url = getArtifactUrl(args.url)
|
31 |
print(artifact_url)
|
32 |
+
getArtifact(artifact_url, args.gh_tokenfile, args.outputfile)
|
33 |
|
34 |
if __name__ == '__main__':
|
35 |
main()
|