-
-
Save iainmcampbell/a7790f42725ffd7029fd to your computer and use it in GitHub Desktop.
gist backup
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
#!/usr/bin/env python | |
# Git clone all my gists | |
import json | |
import urllib | |
from urllib import urlopen | |
from subprocess import call | |
import os | |
USER = 'iainmcampbell' | |
BASE_PATH = os.getcwd() | |
u = urlopen('https://api.github.com/users/'+USER+'/gists') | |
gists = json.load(u) | |
for gist in gists: | |
gist_path = BASE_PATH + '/' + gist['id'] | |
if os.path.exists(gist_path): | |
print( '\n' + gist['id'] + ' exists, pulling') | |
os.chdir(gist_path) | |
call(['git', 'pull', 'origin', 'master']) | |
else: | |
print( '\n' + gist['id'] + ' is new, cloning') | |
os.chdir(BASE_PATH) | |
call(['git', 'clone', 'git://gist.github.com/' + gist['id'] + '.git']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment