# HG changeset patch # User drewp@bigasterisk.com # Date 1357717224 28800 # Node ID 1da34eecdfd852cbcc33fb23819ee53d6b259579 # Parent 90405940c2633f595734376af0dd7003b64c6c85 port to PyGithub so repo creates work again Ignore-this: 5e00f0483c54df98dddda680b00d1318 diff -r 90405940c263 -r 1da34eecdfd8 pydeps --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pydeps Tue Jan 08 23:40:24 2013 -0800 @@ -0,0 +1,1 @@ +PyGithub==1.10.0 diff -r 90405940c263 -r 1da34eecdfd8 sync.py --- a/sync.py Mon Apr 04 01:24:59 2011 -0700 +++ b/sync.py Tue Jan 08 23:40:24 2013 -0800 @@ -1,7 +1,7 @@ #!bin/python -import os, subprocess, urllib2, jsonlib, logging, traceback -from github import github +import os, subprocess, urllib2, json, logging, traceback, time +from github import Github, GithubException logging.basicConfig(level=logging.INFO) log = logging.getLogger() @@ -26,23 +26,34 @@ self.runGitCommand([self.config['darcsToGitCmd'], '--no-verbose', darcsDir]) def runGitCommand(self, args): - subprocess.check_call(args, cwd=self.gitDir(), - env={'SSH_AUTH_SOCK': self.config['SSH_AUTH_SOCK']}) + try: + subprocess.check_call(args, cwd=self.gitDir(), + env={'SSH_AUTH_SOCK': self.config['SSH_AUTH_SOCK'], + 'HOME': os.environ['HOME'], # darcs-to-git uses this + }) + except: + log.error("in %s" % self.gitDir()) + raise def makeGitHubRepo(self): try: - self.gh.repos.create(self.name) - except urllib2.HTTPError: + self.gh.create_repo(self.name) + except GithubException, e: + assert e.data['errors'][0]['message'].startswith('name already exists'), e return self.runGitCommand(['git', 'remote', 'add', 'origin', - 'git@github.com:%s/%s.git' % (self.gh.user, + 'git@github.com:%s/%s.git' % (self.gh.login, self.name)]) def pushToGitHub(self): self.runGitCommand(['git', 'push', 'origin', 'master']) -config = jsonlib.read(open("config.json").read()) -gh = github.GitHub(config['user'], config['gitHubToken']) +config = json.loads(open("config.json").read()) + +# to get this token: +# curl -u drewp https://api.github.com/authorizations -d '{"scopes":["repo"]}' +# from http://developer.github.com/v3/oauth/#oauth-authorizations-api +gh = Github(config['gitHubToken']).get_user() for proj in os.listdir(config['darcsDir']): if 'repo' not in proj: