Skip to content

Instantly share code, notes, and snippets.

@zlsun
Last active December 23, 2015 05:41
Show Gist options
  • Select an option

  • Save zlsun/2715ea2f58790d50a59b to your computer and use it in GitHub Desktop.

Select an option

Save zlsun/2715ea2f58790d50a59b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import requests
from path import Path
from sh import git
user = 'your username'
pswd = 'your password'
req = requests.get('https://api.github.com/users/%s/gists' % user, auth=(user, pswd))
gists = req.json()
if 'message' in gists:
print(gists['message'])
sys.exit(0)
for gist in gists:
gistd = gist['id']
gistUrl = gist['git_pull_url']
# gistUrl = '[email protected]:%s.git' % gistd
print(gistUrl)
p = Path(gistd)
if p.isdir():
with p:
ret = git.pull(gistUrl)
else:
ret = git.clone(gistUrl)
if ret.exit_code != 0:
print('ERROR processing gist %s. Please check output.' % gist['id'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment