Created
February 9, 2015 02:32
-
-
Save taichunmin/460092f531e19f7dd97a to your computer and use it in GitHub Desktop.
download gitlab archive
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
#!/bin/env python3 | |
import urllib, shutil, json, sys | |
import urllib.request | |
import urllib.parse | |
def dl_gitlab_archive(url, private_token, out_filename): | |
try: | |
fields = urllib.parse.urlencode({ | |
'private_token': private_token | |
}) | |
with urllib.request.urlopen(url+'?'+fields) as response, open(out_filename, 'wb') as fout: | |
shutil.copyfileobj(response, fout) | |
except urllib.error.HTTPError as e: | |
print(e) | |
if __name__ == '__main__': | |
print(sys.argv) | |
dl_gitlab_archive(sys.argv[1], sys.argv[2], sys.argv[3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment