Skip to content

Instantly share code, notes, and snippets.

@chrisdickinson
Created August 17, 2010 01:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdickinson/528123 to your computer and use it in GitHub Desktop.
Save chrisdickinson/528123 to your computer and use it in GitHub Desktop.
from dulwich import client
import paramiko
class ParamikoWrapper(object):
def __init__(self, host, command, username, port):
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(host, username=username)
self.streams = self.client.exec_command(command[0])
self.write = self.streams[0].writelines
self.read = self.streams[1].readline
def can_read(self):
return len(select.select([self.streams[1].channel.fileno()], [], [], 0)) > 0
def close(self):
self.client.close()
class ParamikoSSHVendor(object):
def connect_ssh(self, host, command, username=None, port=None):
return ParamikoWrapper(host, command, username, port)
client.get_ssh_vendor = ParamikoSSHVendor
import dulwich
import dko
import os
client = dulwich.client.SSHGitClient('github.com', 22, 'git')
repo = dulwich.repo.Repo(os.path.realpath('.'))
# put a repo you have private access to HERE
print client.fetch('chrisdickinson/wilson.git', repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment