[tor-commits] [arm/master] Renaming tracker's get_resource_usage() and get_connections() to get_value()
atagar at torproject.org
atagar at torproject.org
Mon Jun 23 15:00:33 UTC 2014
commit c109e00ecb066f8e5c6539359d5d969afc35ae56
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Jun 22 19:05:13 2014 -0700
Renaming tracker's get_resource_usage() and get_connections() to get_value()
We use singletons to fetch trackers, so their type is already pretty obvious.
Changing their method names to something more generic so it doesn't sound so
redundant.
---
arm/connections/conn_panel.py | 2 +-
arm/graphing/conn_stats.py | 2 +-
arm/graphing/resource_stats.py | 2 +-
arm/header_panel.py | 2 +-
arm/util/tracker.py | 9 +++++----
5 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/arm/connections/conn_panel.py b/arm/connections/conn_panel.py
index fe9b5a6..491c810 100644
--- a/arm/connections/conn_panel.py
+++ b/arm/connections/conn_panel.py
@@ -517,7 +517,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
# new_connections [(local ip, local port, foreign ip, foreign port)...]
# new_circuits {circuit_id => (status, purpose, path)...}
- new_connections = [(conn.local_address, conn.local_port, conn.remote_address, conn.remote_port) for conn in conn_resolver.get_connections()]
+ new_connections = [(conn.local_address, conn.local_port, conn.remote_address, conn.remote_port) for conn in conn_resolver.get_value()]
new_circuits = {}
for circ in tor_controller().get_circuits():
diff --git a/arm/graphing/conn_stats.py b/arm/graphing/conn_stats.py
index 5e2d2f5..2f8ec11 100644
--- a/arm/graphing/conn_stats.py
+++ b/arm/graphing/conn_stats.py
@@ -45,7 +45,7 @@ class ConnStats(graph_panel.GraphStats):
inbound_count, outbound_count = 0, 0
- for entry in arm.util.tracker.get_connection_tracker().get_connections():
+ for entry in arm.util.tracker.get_connection_tracker().get_value():
local_port = entry.local_port
if local_port in (self.or_port, self.dir_port):
diff --git a/arm/graphing/resource_stats.py b/arm/graphing/resource_stats.py
index 71b6790..856c2b7 100644
--- a/arm/graphing/resource_stats.py
+++ b/arm/graphing/resource_stats.py
@@ -54,7 +54,7 @@ class ResourceStats(graph_panel.GraphStats):
resource_tracker = arm.util.tracker.get_resource_tracker()
if resource_tracker and resource_tracker.run_counter() != self.last_counter:
- resources = resource_tracker.get_resource_usage()
+ resources = resource_tracker.get_value()
self.last_counter = resource_tracker.run_counter()
primary = resources.cpu_sample * 100 # decimal percentage to whole numbers
secondary = resources.memory_bytes / 1048576 # translate size to MB so axis labels are short
diff --git a/arm/header_panel.py b/arm/header_panel.py
index 9bbd211..5f382c3 100644
--- a/arm/header_panel.py
+++ b/arm/header_panel.py
@@ -506,7 +506,7 @@ class Sampling(object):
uname_vals = os.uname()
start_time = stem.util.system.get_start_time(controller.get_pid(None))
- tor_resources = arm.util.tracker.get_resource_tracker().get_resource_usage()
+ tor_resources = arm.util.tracker.get_resource_tracker().get_value()
self.retrieved = time.time()
self.arm_total_cpu_time = sum(os.times()[:3])
diff --git a/arm/util/tracker.py b/arm/util/tracker.py
index 8b06042..02b1943 100644
--- a/arm/util/tracker.py
+++ b/arm/util/tracker.py
@@ -5,6 +5,7 @@ Background tasks for gathering information about the tor process.
get_connection_tracker - provides a ConnectionTracker for our tor process
get_resource_tracker - provides a ResourceTracker for our tor process
+ get_port_usage_tracker - provides a PortUsageTracker for our system
stop_trackers - halts any active trackers
@@ -12,10 +13,10 @@ Background tasks for gathering information about the tor process.
|- ConnectionTracker - periodically checks the connections established by tor
| |- get_custom_resolver - provide the custom conntion resolver we're using
| |- set_custom_resolver - overwrites automatic resolver selecion with a custom resolver
- | +- get_connections - provides our latest connection results
+ | +- get_value - provides our latest connection results
|
|- ResourceTracker - periodically checks the resource usage of tor
- | +- get_resource_usage - provides our latest resource usage results
+ | +- get_value - provides our latest resource usage results
|
|- PortUsageTracker - provides information about port usage on the local system
| +- get_processes_using_ports - mapping of ports to the processes using it
@@ -511,7 +512,7 @@ class ConnectionTracker(Daemon):
self._custom_resolver = resolver
- def get_connections(self):
+ def get_value(self):
"""
Provides a listing of tor's latest connections.
@@ -537,7 +538,7 @@ class ResourceTracker(Daemon):
self._use_proc = proc.is_available() # determines if we use proc or ps for lookups
self._failure_count = 0 # number of times in a row we've failed to get results
- def get_resource_usage(self):
+ def get_value(self):
"""
Provides tor's latest resource usage.
More information about the tor-commits
mailing list