本文整理汇总了Python中ClusterShell.CLI.Utils.NodeSet.remove方法的典型用法代码示例。如果您正苦于以下问题:Python NodeSet.remove方法的具体用法?Python NodeSet.remove怎么用?Python NodeSet.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterShell.CLI.Utils.NodeSet
的用法示例。
在下文中一共展示了NodeSet.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LiveGatherOutputHandler
# 需要导入模块: from ClusterShell.CLI.Utils import NodeSet [as 别名]
# 或者: from ClusterShell.CLI.Utils.NodeSet import remove [as 别名]
class LiveGatherOutputHandler(GatherOutputHandler):
"""Live line-gathered output event handler class."""
def __init__(self, display, nodes):
assert nodes is not None, "cannot gather local command"
GatherOutputHandler.__init__(self, display)
self._nodes = NodeSet(nodes)
self._nodecnt = dict.fromkeys(self._nodes, 0)
self._mtreeq = []
self._offload = 0
def ev_read(self, worker):
# Read new line from node
node = worker.current_node
self._nodecnt[node] += 1
cnt = self._nodecnt[node]
if len(self._mtreeq) < cnt:
self._mtreeq.append(MsgTree())
self._mtreeq[cnt - self._offload - 1].add(node, worker.current_msg)
self._live_line(worker)
def ev_hup(self, worker):
if self._mtreeq and worker.current_node not in self._mtreeq[0]:
# forget a node that doesn't answer to continue live line
# gathering anyway
self._nodes.remove(worker.current_node)
self._live_line(worker)
def _live_line(self, worker):
# if all nodes have replied, display gathered line
while self._mtreeq and len(self._mtreeq[0]) == len(self._nodes):
mtree = self._mtreeq.pop(0)
self._offload += 1
self._runtimer_clean()
nodesetify = lambda v: (v[0], NodeSet.fromlist(v[1]))
for buf, nodeset in sorted(map(nodesetify, mtree.walk()),
cmp=bufnodeset_cmp):
self._display.print_gather(nodeset, buf)
self._runtimer_set_dirty()
def ev_close(self, worker):
# Worker is closing -- it's time to gather results...
self._runtimer_finalize(worker)
for mtree in self._mtreeq:
nodesetify = lambda v: (v[0], NodeSet.fromlist(v[1]))
for buf, nodeset in sorted(map(nodesetify, mtree.walk()),
cmp=bufnodeset_cmp):
self._display.print_gather(nodeset, buf)
self._close_common(worker)
# Notify main thread to update its prompt
self.update_prompt(worker)