Skip to content

Instantly share code, notes, and snippets.

@taichunmin
Created February 9, 2015 02:32
Show Gist options
  • Save taichunmin/460092f531e19f7dd97a to your computer and use it in GitHub Desktop.
Save taichunmin/460092f531e19f7dd97a to your computer and use it in GitHub Desktop.
download gitlab archive
#!/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