commit 1d1776e459a65b75af4f0525ac57dce6d2f02df8 Author: Damian Johnson atagar@torproject.org Date: Thu Aug 18 09:26:57 2011 -0700
Adding port usage information to count dialog
When showing exiting port usages also including a label saying what they're for. --- src/cli/connections/countPopup.py | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/cli/connections/countPopup.py b/src/cli/connections/countPopup.py index 341087f..7904519 100644 --- a/src/cli/connections/countPopup.py +++ b/src/cli/connections/countPopup.py @@ -8,9 +8,10 @@ import operator import cli.controller import cli.popups
-from util import enum, log, uiTools +from util import connections, enum, log, uiTools
CountType = enum.Enum("CLIENT_LOCALE", "EXIT_PORT") +EXIT_USAGE_WIDTH = 15
def showCountDialog(countType, counts): """ @@ -60,10 +61,23 @@ def showCountDialog(countType, counts): valWidth = max(valWidth, len(str(v))) valueTotal += v
+ # extra space since we're adding usage informaion + if countType == CountType.EXIT_PORT: + keyWidth += EXIT_USAGE_WIDTH + labelFormat = "%%-%is %%%ii (%%%%%%-2i)" % (keyWidth, valWidth)
for i in range(height - 4): k, v = sortedCounts[i] + + # includes a port usage column + if countType == CountType.EXIT_PORT: + usage = connections.getPortUsage(k) + + if usage: + keyFormat = "%%-%is %%s" % (keyWidth - EXIT_USAGE_WIDTH) + k = keyFormat % (k, usage[:EXIT_USAGE_WIDTH - 3]) + label = labelFormat % (k, v, v * 100 / valueTotal) popup.addstr(i + 1, 2, label, curses.A_BOLD | uiTools.getColor("green"))
tor-commits@lists.torproject.org