예제 #1
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']
예제 #2
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']