Author: atagar Date: 2011-04-12 16:15:00 +0000 (Tue, 12 Apr 2011) New Revision: 24594
Modified: arm/trunk/src/interface/controller.py arm/trunk/src/interface/descriptorPopup.py Log: Dropping raw torctl access from the descriptor popup (simpler, takes advantage of caching, and allows for restarts)
Modified: arm/trunk/src/interface/controller.py =================================================================== --- arm/trunk/src/interface/controller.py 2011-04-12 16:03:46 UTC (rev 24593) +++ arm/trunk/src/interface/controller.py 2011-04-12 16:15:00 UTC (rev 24594) @@ -1462,7 +1462,7 @@ if key in (curses.KEY_DOWN, curses.KEY_UP, curses.KEY_PPAGE, curses.KEY_NPAGE): panels["conn"].handleKey(key) elif key in (ord('d'), ord('D')): - descriptorPopup.showDescriptorPopup(panels["popup"], stdscr, conn, panels["conn"]) + descriptorPopup.showDescriptorPopup(panels["popup"], stdscr, panels["conn"]) panels["conn"].redraw(True)
panels["conn"].showLabel = True @@ -1481,7 +1481,7 @@ panels["conn"].showLabel = False panels["conn"].redraw(True)
- descriptorPopup.showDescriptorPopup(panels["popup"], stdscr, conn, panels["conn"]) + descriptorPopup.showDescriptorPopup(panels["popup"], stdscr, panels["conn"])
setPauseState(panels, isPaused, page) curses.halfdelay(REFRESH_RATE * 10) # reset normal pausing behavior
Modified: arm/trunk/src/interface/descriptorPopup.py =================================================================== --- arm/trunk/src/interface/descriptorPopup.py 2011-04-12 16:03:46 UTC (rev 24593) +++ arm/trunk/src/interface/descriptorPopup.py 2011-04-12 16:15:00 UTC (rev 24594) @@ -9,7 +9,7 @@
import controller import connPanel -from util import panel, uiTools +from util import panel, torTools, uiTools
# field keywords used to identify areas for coloring LINE_NUM_COLOR = "yellow" @@ -28,8 +28,7 @@ State attributes of popup window for consensus descriptions. """
- def __init__(self, conn): - self.conn = conn + def __init__(self): self.fingerprint = "" self.entryColor = "white" self.text = [] @@ -47,18 +46,19 @@ self.showLineNum = False self.text.append(UNRESOLVED_MSG) else: + conn = torTools.getConn() + try: self.showLineNum = True - nsCommand = "ns/id/%s" % fingerprint - self.text.append(nsCommand) - self.text = self.text + self.conn.get_info(nsCommand)[nsCommand].split("\n") + self.text.append("ns/id/%s" % fingerprint) + self.text += conn.getConsensusEntry(fingerprint).split("\n") except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed): self.text = self.text + [ERROR_MSG, ""]
try: descCommand = "desc/id/%s" % fingerprint - self.text.append(descCommand) - self.text = self.text + self.conn.get_info(descCommand)[descCommand].split("\n") + self.text.append("desc/id/%s" % fingerprint) + self.text += conn.getDescriptorEntry(fingerprint).split("\n") except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed): self.text = self.text + [ERROR_MSG]
@@ -68,7 +68,7 @@ elif key == curses.KEY_PPAGE: self.scroll = max(self.scroll - height, 0) elif key == curses.KEY_NPAGE: self.scroll = max(0, min(self.scroll + height, len(self.text) - height))
-def showDescriptorPopup(popup, stdscr, conn, connectionPanel): +def showDescriptorPopup(popup, stdscr, connectionPanel): """ Presents consensus descriptor in popup window with the following controls: Up, Down, Page Up, Page Down - scroll descriptor @@ -76,7 +76,7 @@ Enter, Space, d, D - close popup """
- properties = PopupProperties(conn) + properties = PopupProperties() isVisible = True
if not panel.CURSES_LOCK.acquire(False): return
tor-commits@lists.torproject.org