-
-
Save berndweiss/3847428 to your computer and use it in GitHub Desktop.
Revisions
-
leetrout revised this gist
Feb 28, 2012 . 2 changed files with 9 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,11 @@ USAGE :: python ghclone.py Follow the prompts Notes ===== You should make sure you have ssh keys setup or you'll have to enter your username and password every time. This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() API_BASE_URL = "https://api.github.com" def clone(): password_mgr.add_password(None, API_BASE_URL, cred['user'], cred['pass']) handler = urllib2.HTTPBasicAuthHandler(password_mgr) opener = urllib2.build_opener(handler) @@ -35,4 +35,4 @@ def sync(): cwd = os.getcwd() target_dir = os.path.abspath(os.path.expanduser( raw_input('Target directory (%s): ' % cwd) or cwd)) clone() -
leetrout revised this gist
Feb 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def sync(): for repo in repos: url = repo['git_url'] call(['git', 'clone', url]) print("cloned %s" % url) cnt += 1 print('cloned %d repos in %s' % (cnt, target_dir)) -
leetrout created this gist
Feb 28, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ USAGE ===== :: python ghsync.py Follow the prompts This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ import getpass import json import os from subprocess import call import urllib2 cred = { 'user': '', 'pass': '' } password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() API_BASE_URL = "https://api.github.com" def sync(): password_mgr.add_password(None, API_BASE_URL, cred['user'], cred['pass']) handler = urllib2.HTTPBasicAuthHandler(password_mgr) opener = urllib2.build_opener(handler) page = opener.open(API_BASE_URL + '/user/repos') data = page.read() page.close() repos = json.loads(data) os.chdir(target_dir) cnt = 0 for repo in repos: url = repo['git_url'] call(['git', 'clone', url]) print "cloned %s" % url cnt += 1 print('cloned %d repos in %s' % (cnt, target_dir)) if __name__ == '__main__': cred['user'] = raw_input('Username: ') cred['pass'] = getpass.getpass('Password: ') cwd = os.getcwd() target_dir = os.path.abspath(os.path.expanduser( raw_input('Target directory (%s): ' % cwd) or cwd)) sync()