Mercurial > code > home > repos > reposync
changeset 3:4077903a9520
upgrade PyGithub. use keychain for ssh sock path
Ignore-this: ab5c52463f0b6cc01bc3dece4bc2192f
author | drewp@bigasterisk.com |
---|---|
date | Mon, 27 May 2013 01:08:16 -0700 |
parents | 22ccc05756de |
children | f714a6a7842c |
files | pydeps sync.py |
diffstat | 2 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pydeps Tue Jan 08 23:41:13 2013 -0800 +++ b/pydeps Mon May 27 01:08:16 2013 -0700 @@ -1,1 +1,1 @@ -PyGithub==1.10.0 +PyGithub==1.14.2
--- a/sync.py Tue Jan 08 23:41:13 2013 -0800 +++ b/sync.py Mon May 27 01:08:16 2013 -0700 @@ -1,6 +1,6 @@ #!bin/python -import os, subprocess, urllib2, json, logging, traceback, time +import os, subprocess, urllib2, json, logging, traceback, time, re from github import Github, GithubException logging.basicConfig(level=logging.INFO) log = logging.getLogger() @@ -31,7 +31,7 @@ try: os.rmdir(os.path.join(darcsDir, 'darcs_testing_for_nfs')) except OSError: pass - self.runGitCommand([self.config['darcsToGitCmd'], '--no-verbose', darcsDir]) + self.runGitCommand([self.config['darcsToGitCmd'], '--verbose', darcsDir]) def runGitCommand(self, args): try: @@ -47,7 +47,7 @@ try: self.gh.create_repo(self.name) except GithubException, e: - assert e.data['errors'][0]['message'].startswith('name already exists'), e + assert e.data['errors'][0]['message'].startswith('name already exists'), (e, self.name) return self.runGitCommand(['git', 'remote', 'add', 'origin', 'git@github.com:%s/%s.git' % (self.gh.login, @@ -56,7 +56,18 @@ def pushToGitHub(self): self.runGitCommand(['git', 'push', 'origin', 'master']) +def getSshAuthSock(): + keychain = subprocess.check_output([ + "keychain", "--noask", "--quiet", "--eval", "id_rsa"]) + m = re.search(r'SSH_AUTH_SOCK=([^; \n]+)', keychain) + if m is not None: + return m.group(1) + else: + raise ValueError("couldn't find SSH_AUTH_SOCK in output " + "from keychain: %r" % keychain) + config = json.loads(open("config.json").read()) +config['SSH_AUTH_SOCK'] = getSshAuthSock() # to get this token: # curl -u drewp https://api.github.com/authorizations -d '{"scopes":["repo"]}'