commit 6846e119190e1de29d70ba25fb4db8d40c2b4b95 Author: Damian Johnson atagar@torproject.org Date: Mon Jul 27 10:03:48 2015 -0700
Properly use application resolution in the panel
Our connection panel still expected a tuple, causing a stacktrace. Fixing that, along with a couple issues with the tracker itself finally using this in a live instance hilighted:
* system.call() raised an OSError rather than the exptected IOError * we were still calling lsof for zero ports, triggering failures --- nyx/connections/conn_panel.py | 13 ++++--------- nyx/util/tracker.py | 10 +++++++--- 2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py index b977e7d..e40a431 100644 --- a/nyx/connections/conn_panel.py +++ b/nyx/connections/conn_panel.py @@ -540,15 +540,10 @@ class ConnectionPanel(panel.Panel, threading.Thread): line_port = line.connection.local_port if is_local else line.connection.remote_port
if line_port in app_results: - # sets application attributes if there's a result with this as the - # inbound port + result = app_results[line_port]
- for inbound_port, outbound_port, cmd, pid in app_results[line_port]: - app_port = outbound_port if is_local else inbound_port - - if line_port == app_port: - line.application_name = cmd - line.application_pid = pid - line.is_application_resolving = False + line.application_name = result.name + line.application_pid = result.pid + line.is_application_resolving = False else: line.is_application_resolving = self._app_resolver.is_alive diff --git a/nyx/util/tracker.py b/nyx/util/tracker.py index ebb3b84..f6219ad 100644 --- a/nyx/util/tracker.py +++ b/nyx/util/tracker.py @@ -299,8 +299,11 @@ def _process_for_ports(local_ports, remote_ports): # python 2462 atagar 3u IPv4 14047 0t0 TCP localhost:37277->localhost:9051 (ESTABLISHED) # python 3444 atagar 3u IPv4 22023 0t0 TCP localhost:51849->localhost:9051 (ESTABLISHED)
- lsof_cmd = 'lsof -nP ' + ' '.join(['-i tcp:%s' % port for port in (local_ports + remote_ports)]) - lsof_call = system.call(lsof_cmd) + try: + lsof_cmd = 'lsof -nP ' + ' '.join(['-i tcp:%s' % port for port in (local_ports + remote_ports)]) + lsof_call = system.call(lsof_cmd) + except OSError as exc: + raise IOError(exc)
if lsof_call: results = {} @@ -698,7 +701,8 @@ class PortUsageTracker(Daemon): ports.remove(port)
try: - result.update(_process_for_ports(ports, ports)) + if ports: + result.update(_process_for_ports(ports, ports))
self._processes_for_ports = result self._failure_count = 0