commit 4474efa7379d855ede60f6edf1c678654be437a0 Author: Damian Johnson atagar@torproject.org Date: Thu May 12 20:53:46 2011 -0700
Moving log snapshot saving to the log panel --- src/cli/controller.py | 30 ------------------------------ src/cli/logPanel.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 30 deletions(-)
diff --git a/src/cli/controller.py b/src/cli/controller.py index 84205cb..1384c4d 100644 --- a/src/cli/controller.py +++ b/src/cli/controller.py @@ -812,36 +812,6 @@ def drawTorMonitor(stdscr, startTime, loggedEvents, isBlindMode): panels["graph"].bounds = graphing.graphPanel.Bounds.next(panels["graph"].bounds)
selectiveRefresh(panels, page) - elif page == 0 and (key == ord('a') or key == ord('A')): - # allow user to enter a path to take a snapshot - abandons if left blank - panel.CURSES_LOCK.acquire() - try: - setPauseState(panels, isPaused, page, True) - - # provides prompt - panels["control"].setMsg("Path to save log snapshot: ") - panels["control"].redraw(True) - - # gets user input (this blocks monitor updates) - pathInput = panels["control"].getstr(0, 27) - - if pathInput: - try: - panels["log"].saveSnapshot(pathInput) - panels["control"].setMsg("Saved: %s" % pathInput, curses.A_STANDOUT) - panels["control"].redraw(True) - time.sleep(2) - except IOError, exc: - panels["control"].setMsg("Unable to save snapshot: %s" % sysTools.getFileErrorMsg(exc), curses.A_STANDOUT) - panels["control"].redraw(True) - time.sleep(2) - - panels["control"].setMsg(CTL_PAUSED if isPaused else CTL_HELP) - setPauseState(panels, isPaused, page) - finally: - panel.CURSES_LOCK.release() - - panels["graph"].redraw(True) else: for pagePanel in getPanels(page + 1): isKeystrokeConsumed = pagePanel.handleKey(key) diff --git a/src/cli/logPanel.py b/src/cli/logPanel.py index 75cdab5..34bf759 100644 --- a/src/cli/logPanel.py +++ b/src/cli/logPanel.py @@ -867,6 +867,16 @@ class LogPanel(panel.Panel, threading.Thread): except ValueError, exc: popups.showMsg("Invalid flags: %s" % str(exc), 2) finally: popups.finalize() + elif key == ord('a') or key == ord('A'): + # lets user enter a path to take a snapshot, canceling if left blank + pathInput = popups.inputPrompt("Path to save log snapshot: ") + + if pathInput: + try: + self.saveSnapshot(pathInput) + popups.showMsg("Saved: %s" % pathInput, 2) + except IOError, exc: + popups.showMsg("Unable to save snapshot: %s" % sysTools.getFileErrorMsg(exc), 2) else: isKeystrokeConsumed = False
return isKeystrokeConsumed
tor-commits@lists.torproject.org