当前位置: 首页>>代码示例>>Python>>正文


Python WorkerPdsh.iter_retcodes方法代码示例

本文整理汇总了Python中ClusterShell.Worker.Pdsh.WorkerPdsh.iter_retcodes方法的典型用法代码示例。如果您正苦于以下问题:Python WorkerPdsh.iter_retcodes方法的具体用法?Python WorkerPdsh.iter_retcodes怎么用?Python WorkerPdsh.iter_retcodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClusterShell.Worker.Pdsh.WorkerPdsh的用法示例。


在下文中一共展示了WorkerPdsh.iter_retcodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testWorkerPdshRetcodes

# 需要导入模块: from ClusterShell.Worker.Pdsh import WorkerPdsh [as 别名]
# 或者: from ClusterShell.Worker.Pdsh.WorkerPdsh import iter_retcodes [as 别名]
    def testWorkerPdshRetcodes(self):
        # test retcodes on distant pdsh workers
        worker = WorkerPdsh(HOSTNAME, command="/bin/sh -c 'exit 3'",
                            handler=None, timeout=None)
        self._task.schedule(worker)
        self._task.resume()

        cnt = 2
        for rc, keys in worker.iter_retcodes():
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(len(keys), 1)
            self.assertEqual(keys[0], HOSTNAME)

        self.assertEqual(cnt, 1)

        for rc, keys in worker.iter_retcodes(HOSTNAME):
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(len(keys), 1)
            self.assertEqual(keys[0], HOSTNAME)

        self.assertEqual(cnt, 0)

        # test node_retcode
        self.assertEqual(worker.node_retcode(HOSTNAME), 3)   # 1.2.91+
        self.assertEqual(worker.node_rc(HOSTNAME), 3)

        # test node_retcode failure
        self.assertRaises(KeyError, worker.node_retcode, "dummy")

        # test max retcode API
        self.assertEqual(self._task.max_retcode(), 3)
开发者ID:cea-hpc,项目名称:clustershell,代码行数:35,代码来源:TaskDistantPdshMixin.py

示例2: testWorkerPdshRetcodes

# 需要导入模块: from ClusterShell.Worker.Pdsh import WorkerPdsh [as 别名]
# 或者: from ClusterShell.Worker.Pdsh.WorkerPdsh import iter_retcodes [as 别名]
    def testWorkerPdshRetcodes(self):
        """test retcodes on distant pdsh workers"""
        task = task_self()
        self.assert_(task != None)

        worker = WorkerPdsh("localhost", command="/bin/sh -c 'exit 3'",
                            handler=None, timeout=None)
        task.schedule(worker)
        task.resume()

        cnt = 2
        for rc, keys in worker.iter_retcodes():
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(len(keys), 1)
            self.assert_(keys[0] == "localhost")

        self.assertEqual(cnt, 1)

        for rc, keys in worker.iter_retcodes("localhost"):
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(len(keys), 1)
            self.assert_(keys[0] == "localhost")

        self.assertEqual(cnt, 0)

        # test node_retcode
        self.assertEqual(worker.node_retcode("localhost"), 3)   # 1.2.91+
        self.assertEqual(worker.node_rc("localhost"), 3)

        # test node_retcode failure
        self.assertRaises(KeyError, worker.node_retcode, "dummy")

        # test max retcode API
        self.assertEqual(task.max_retcode(), 3)
开发者ID:ChristianKniep,项目名称:clustershell,代码行数:38,代码来源:TaskDistantPdshTest.py


注:本文中的ClusterShell.Worker.Pdsh.WorkerPdsh.iter_retcodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。