Esempio n. 1
0
 def __init__(self):
     config = configparser.ConfigParser()
     config.read("../config.ini", encoding='utf-8')
     self.hostname = config.get("BMC", "ip")
     self.username = config.get("BMC", "userid")
     self.password = config.get("BMC", "password")
     self.ssh_client = paramiko.SSHClient()
     self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
     self.ssh_client.connect(hostname=self.hostname,
                             username=self.username,
                             password=self.password)
     self.sftp_server = paramiko.SFTPServer()
Esempio n. 2
0
    def setup(self):
        self.wrap_for_latency()

        # Re-import these as locals, so that they're still accessible during
        # interpreter shutdown (when all module globals get set to None, leading
        # to confusing errors like "'NoneType' object has no attribute 'error'".

        class FakeChannel(object):
            def get_transport(self):
                return self

            def get_log_channel(self):
                return 'brz.paramiko'

            def get_name(self):
                return '1'

            def get_hexdump(self):
                return False

            def close(self):
                pass

        tcs = self.server.test_case_server
        sftp_server = paramiko.SFTPServer(FakeChannel(),
                                          'sftp',
                                          StubServer(tcs),
                                          StubSFTPServer,
                                          root=tcs._root,
                                          home=tcs._server_homedir)
        self.sftp_server = sftp_server
        sys_stderr = sys.stderr  # Used in error reporting during shutdown
        try:
            sftp_server.start_subsystem(
                'sftp', None, ssh.SocketAsChannelAdapter(self.request))
        except socket.error as e:
            if (len(e.args) > 0) and (e.args[0] == errno.EPIPE):
                # it's okay for the client to disconnect abruptly
                # (bug in paramiko 1.6: it should absorb this exception)
                pass
            else:
                raise
        except Exception as e:
            # This typically seems to happen during interpreter shutdown, so
            # most of the useful ways to report this error won't work.
            # Writing the exception type, and then the text of the exception,
            # seems to be the best we can do.
            # FIXME: All interpreter shutdown errors should have been related
            # to daemon threads, cleanup needed -- vila 20100623
            sys_stderr.write('\nEXCEPTION %r: ' % (e.__class__, ))
            sys_stderr.write('%s\n\n' % (e, ))
Esempio n. 3
0
    def setup(self):
        self.wrap_for_latency()

        # Re-import these as locals, so that they're still accessible during
        # interpreter shutdown (when all module globals get set to None, leading
        # to confusing errors like "'NoneType' object has no attribute 'error'".
        class FakeChannel(object):
            def get_transport(self):
                return self

            def get_log_channel(self):
                return 'bzr.paramiko'

            def get_name(self):
                return '1'

            def get_hexdump(self):
                return False

            def close(self):
                pass

        tcs = self.server.test_case_server
        sftp_server = paramiko.SFTPServer(FakeChannel(),
                                          'sftp',
                                          StubServer(tcs),
                                          StubSFTPServer,
                                          root=tcs._root,
                                          home=tcs._server_homedir)
        self.sftp_server = sftp_server
        sys_stderr = sys.stderr  # Used in error reporting during shutdown
        try:
            sftp_server.start_subsystem(
                'sftp', None, ssh.SocketAsChannelAdapter(self.request))
        except socket.error, e:
            if (len(e.args) > 0) and (e.args[0] == errno.EPIPE):
                # it's okay for the client to disconnect abruptly
                # (bug in paramiko 1.6: it should absorb this exception)
                pass
            else:
                raise
Esempio n. 4
0
__author__ = 'meng'

import paramiko

sftp_server = paramiko.SFTPServer()

sftp_server.start()