Created
August 17, 2010 01:44
-
-
Save chrisdickinson/528123 to your computer and use it in GitHub Desktop.
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
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 |
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
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