コード例 #1
0
    def _getBatchOutput(self, f):
        fn = tempfile.mktemp()
        open(fn, 'w').write(f)
        port = self.server.getHost().port
        cmds = ('-p %i -l testuser '
                    '-K unix '
                    '-a '
                    '-v -b %s 127.0.0.1') % (port, fn)
        cmds = test_conch._makeArgs(cmds.split(), mod='cftp')[1:]
        log.msg('running %s %s' % (sys.executable, cmds))
        env = os.environ.copy()
        env['PYTHONPATH'] = os.pathsep.join(sys.path)

        self.server.factory.expectedLoseConnection = 1

        d = getProcessOutputAndValue(sys.executable, cmds, env=env)

        def _cleanup(res):
            os.remove(fn)
            return res

        d.addCallback(lambda res: res[0])
        d.addBoth(_cleanup)

        return d
コード例 #2
0
    def _getBatchOutput(self, f):
        fn = tempfile.mktemp()
        open(fn, 'w').write(f)
        l = []
        port = self.server.getHost().port
        cmds = ('-p %i -l testuser '
                    '--known-hosts kh_test '
                    '--user-authentications publickey '
                    '--host-key-algorithms ssh-rsa '
                    '-K direct '
                    '-i dsa_test '
                    '-a --nocache '
                    '-v -b %s 127.0.0.1') % (port, fn)
        cmds = test_conch._makeArgs(cmds.split(), mod='cftp')[1:]
        log.msg('running %s %s' % (sys.executable, cmds))
        env = os.environ.copy()
        env['PYTHONPATH'] = os.pathsep.join(sys.path)

        self.server.factory.expectedLoseConnection = 1

        d = getProcessOutputAndValue(sys.executable, cmds, env=env)

        def _cleanup(res):
            os.remove(fn)
            return res

        d.addCallback(lambda res: res[0])
        d.addBoth(_cleanup)

        return d
コード例 #3
0
ファイル: test_cftp.py プロジェクト: hitzjd/Balance-Simulate
 def _getBatchOutput(self, f):
     fn = tempfile.mktemp()
     open(fn, 'w').write(f)
     l = []
     port = self.server.getHost().port
     cmds = ('-p %i -l testuser '
             '--known-hosts kh_test '
             '--user-authentications publickey '
             '--host-key-algorithms ssh-rsa '
             '-K direct '
             '-i dsa_test '
             '-a --nocache '
             '-v -b %s 127.0.0.1') % (port, fn)
     cmds = test_conch._makeArgs(cmds.split(), mod='cftp')[1:]
     log.msg('running %s %s' % (sys.executable, cmds))
     env = os.environ.copy()
     env['PYTHONPATH'] = os.pathsep.join(sys.path)
     d = getProcessOutputAndValue(sys.executable, cmds, env=env)
     d.setTimeout(10)
     d.addBoth(l.append)
     while not l:
         if hasattr(self.server.factory, 'proto'):
             self.server.factory.proto.expectedLoseConnection = 1
         reactor.iterate(0.1)
     os.remove(fn)
     result = l[0]
     if isinstance(result, failure.Failure):
         raise result.value
     else:
         log.msg(result[1])
         return result[0]
コード例 #4
0
    def setUp(self):
        CFTPClientTestBase.setUp(self)

        self.startServer()
        cmds = ('-p %i -l testuser '
               '--known-hosts kh_test '
               '--user-authentications publickey '
               '--host-key-algorithms ssh-rsa '
               '-K direct '
               '-i dsa_test '
               '-a --nocache '
               '-v '
               '127.0.0.1')
        port = self.server.getHost().port
        cmds = test_conch._makeArgs((cmds % port).split(), mod='cftp')
        log.msg('running %s %s' % (sys.executable, cmds))
        self.processProtocol = SFTPTestProcess()

        env = os.environ.copy()
        env['PYTHONPATH'] = os.pathsep.join(sys.path)
        reactor.spawnProcess(self.processProtocol, sys.executable, cmds,
                             env=env)

        timeout = time.time() + 10
        while (not self.processProtocol.buffer) and (time.time() < timeout):
            reactor.iterate(0.1)
        if time.time() > timeout:
            self.skip = "couldn't start process"
        else:
            self.processProtocol.clearBuffer()
コード例 #5
0
ファイル: test_cftp.py プロジェクト: galaxysd/BitTorrent
 def _getBatchOutput(self, f):
     fn = tempfile.mktemp()
     open(fn, 'w').write(f)
     l = []
     port = self.server.getHost().port
     cmds = ('-p %i -l testuser '
                 '--known-hosts kh_test '
                 '--user-authentications publickey '
                 '--host-key-algorithms ssh-rsa '
                 '-K direct '
                 '-i dsa_test '
                 '-a --nocache '
                 '-v -b %s 127.0.0.1') % (port, fn)
     cmds = test_conch._makeArgs(cmds.split(), mod='cftp')[1:]
     log.msg('running %s %s' % (sys.executable, cmds))
     env = os.environ.copy()
     env['PYTHONPATH'] = os.pathsep.join(sys.path)
     d = getProcessOutputAndValue(sys.executable, cmds, env=env)
     d.setTimeout(10)
     d.addBoth(l.append)
     while not l:
         if hasattr(self.server.factory, 'proto'):
             self.server.factory.proto.expectedLoseConnection = 1
         reactor.iterate(0.1)
     os.remove(fn)
     result = l[0]
     if isinstance(result, failure.Failure):
         raise result.value
     else:
         log.msg(result[1])
         return result[0]