소스 검색

Add SSHVendor abstraction class.

Jelmer Vernooij 11 년 전
부모
커밋
bb6c003e4a
1개의 변경된 파일20개의 추가작업 그리고 1개의 파일을 삭제
  1. 20 1
      dulwich/client.py

+ 20 - 1
dulwich/client.py

@@ -637,6 +637,24 @@ class SubprocessGitClient(TraditionalGitClient):
 
 
 class SSHVendor(object):
+    """A client side SSH implementation."""
+
+    def connect_ssh(self, host, command, username=None, port=None):
+        """Connect to an SSH server.
+
+        Run a command remotely and return a file-like object for interaction
+        with the remote command.
+
+        :param host: Host name
+        :param command: Command to run
+        :param username: Optional ame of user to log in as
+        :param port: Optional SSH port to use
+        """
+        raise NotImplementedError(self.connect_ssh)
+
+
+class SubprocessSSHVendor(SSHVendor):
+    """SSH vendor that shells out to the local 'ssh' command."""
 
     def connect_ssh(self, host, command, username=None, port=None):
         import subprocess
@@ -652,8 +670,9 @@ class SSHVendor(object):
                                 stdout=subprocess.PIPE)
         return SubprocessWrapper(proc)
 
+
 # Can be overridden by users
-get_ssh_vendor = SSHVendor
+get_ssh_vendor = SubprocessSSHVendor
 
 
 class SSHGitClient(TraditionalGitClient):