本文整理汇总了Python中stem.control.Controller.getPanel方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.getPanel方法的具体用法?Python Controller.getPanel怎么用?Python Controller.getPanel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stem.control.Controller
的用法示例。
在下文中一共展示了Controller.getPanel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initController
# 需要导入模块: from stem.control import Controller [as 别名]
# 或者: from stem.control.Controller import getPanel [as 别名]
def initController(stdscr, startTime):
"""
Spawns the controller, and related panels for it.
Arguments:
stdscr - curses window
"""
global ARM_CONTROLLER
# initializes the panels
stickyPanels = [cli.headerPanel.HeaderPanel(stdscr, startTime), LabelPanel(stdscr)]
pagePanels, firstPagePanels = [], []
# first page: graph and log
if CONFIG["features.panels.show.graph"]:
firstPagePanels.append(cli.graphing.graphPanel.GraphPanel(stdscr))
if CONFIG["features.panels.show.log"]:
expandedEvents = cli.logPanel.expandEvents(CONFIG["startup.events"])
firstPagePanels.append(cli.logPanel.LogPanel(stdscr, expandedEvents))
if firstPagePanels:
pagePanels.append(firstPagePanels)
# second page: connections
if not CONFIG["startup.blindModeEnabled"] and CONFIG["features.panels.show.connection"]:
pagePanels.append([cli.connections.connPanel.ConnectionPanel(stdscr)])
# third page: config
if CONFIG["features.panels.show.config"]:
pagePanels.append([cli.configPanel.ConfigPanel(stdscr, cli.configPanel.State.TOR)])
# fourth page: torrc
if CONFIG["features.panels.show.torrc"]:
pagePanels.append([cli.torrcPanel.TorrcPanel(stdscr, cli.torrcPanel.Config.TORRC)])
# initializes the controller
ARM_CONTROLLER = Controller(stdscr, stickyPanels, pagePanels)
# additional configuration for the graph panel
graphPanel = ARM_CONTROLLER.getPanel("graph")
if graphPanel:
# statistical monitors for graph
bwStats = cli.graphing.bandwidthStats.BandwidthStats()
graphPanel.addStats(GraphStat.BANDWIDTH, bwStats)
graphPanel.addStats(GraphStat.SYSTEM_RESOURCES, cli.graphing.resourceStats.ResourceStats())
if not CONFIG["startup.blindModeEnabled"]:
graphPanel.addStats(GraphStat.CONNECTIONS, cli.graphing.connStats.ConnStats())
# sets graph based on config parameter
try:
initialStats = GRAPH_INIT_STATS.get(CONFIG["features.graph.type"])
graphPanel.setStats(initialStats)
except ValueError:
pass # invalid stats, maybe connections when in blind mode
# prepopulates bandwidth values from state file
if CONFIG["features.graph.bw.prepopulate"] and torTools.getConn().isAlive():
isSuccessful = bwStats.prepopulateFromState()
if isSuccessful:
graphPanel.updateInterval = 4