Ejemplo n.º 1
0
 def testCopyTo(self):
     client = PSSHClient(['localhost', 'localhost'])
     client.connect()
     tasks = client.copy_to('/tmp/a', '/tmp/b')
     self.assertIsNotNone(tasks, "failed to copy to")
     output = []
     tasks.wait(output)  # , "failed to copy to")
     for item in output:
         print item['hostname'], item['exit_code']
         print item['stdout']
         print item['stderr']
         print item['exception']
Ejemplo n.º 2
0
 def testCancel(self):
     client = PSSHClient(['localhost', 'localhost'])
     client.connect()
     tasks = client.exec_command("ls -la; sleep 10; ls")
     self.assertIsNotNone(tasks, "failed to exec_command")
     tasks.cancel()
     output = []
     print tasks.wait(output)
     for item in output:
         print item['hostname'], item['exit_code']
         print item['stdout']
         print item['stderr']
         print item['exception']
Ejemplo n.º 3
0
 def testConnect(self):
     client = PSSHClient(['localhost', 'localhost'])
     client.connect()
     self.assertEqual(len(client._connections), 2, "failed to connect")
     client.close()
     self.assertIsNone(client._connections, "failed to reset connection")
     client.close()
     client.connect()
     self.assertEqual(len(client._connections), 2, "failed to connect")
     self.assertRaises(RuntimeError, client.connect)
Ejemplo n.º 4
0
    def testExecLs(self):
        client = PSSHClient(['localhost', 'localhost'])
        client.connect()
        tasks = client.exec_command("ls -la")
        self.assertIsNotNone(tasks, "failed to exec_command")
        self.assertTrue(tasks.wait(), "failed to exec_command")
        output = []
        self.assertTrue(tasks.wait(output), "failed to exec_command")
        for item in output:
            print item['hostname'], item['exit_code']
            print item['stdout']
            print item['stderr']

        tasks = client.exec_command("ls")
        self.assertIsNotNone(tasks, "failed to exec_command")
        self.assertTrue(tasks.wait(), "failed to exec_command")
        output = []
        self.assertTrue(tasks.wait(output), "failed to exec_command")
        for item in output:
            print item['hostname'], item['exit_code']
            print item['stdout']
            print item['stderr']