commit 98e8d6993909089fd57bdcab01f9851b7cafa3f1 Author: Damian Johnson atagar@torproject.org Date: Mon Sep 1 20:41:47 2014 -0700
Using stem's new util function names
Accounting for the newely renamed stem util functions. --- arm/config_panel.py | 4 ++-- arm/connections/conn_entry.py | 2 +- arm/controller.py | 2 +- arm/graphing/bandwidth_stats.py | 26 +++++++++++++------------- arm/graphing/graph_panel.py | 2 +- arm/graphing/resource_stats.py | 4 ++-- arm/header_panel.py | 6 +++--- arm/starter.py | 2 +- arm/util/tor_config.py | 6 +++--- arm/util/tracker.py | 4 ++-- run_tests.py | 4 ++-- 11 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/arm/config_panel.py b/arm/config_panel.py index e71948b..c2dac4b 100644 --- a/arm/config_panel.py +++ b/arm/config_panel.py @@ -205,9 +205,9 @@ class ConfigEntry(): elif self.get(Field.TYPE) == "Boolean" and conf_value in ("0", "1"): conf_value = "False" if conf_value == "0" else "True" elif self.get(Field.TYPE) == "DataSize" and conf_value.isdigit(): - conf_value = str_tools.get_size_label(int(conf_value)) + conf_value = str_tools.size_label(int(conf_value)) elif self.get(Field.TYPE) == "TimeInterval" and conf_value.isdigit(): - conf_value = str_tools.get_time_label(int(conf_value), is_long = True) + conf_value = str_tools.time_label(int(conf_value), is_long = True)
return conf_value
diff --git a/arm/connections/conn_entry.py b/arm/connections/conn_entry.py index 4b9a017..f3ea97a 100644 --- a/arm/connections/conn_entry.py +++ b/arm/connections/conn_entry.py @@ -351,7 +351,7 @@ class ConnectionLine(entries.ConnectionPanelLine): else: time_prefix = ""
- time_label = time_prefix + "%5s" % str_tools.get_time_label(current_time - self.start_time, 1) + time_label = time_prefix + "%5s" % str_tools.time_label(current_time - self.start_time, 1) my_listing[2] = (time_label, my_listing[2][1])
return my_listing diff --git a/arm/controller.py b/arm/controller.py index f18af9c..4a864b9 100644 --- a/arm/controller.py +++ b/arm/controller.py @@ -145,7 +145,7 @@ def init_controller(stdscr, start_time):
if tor_pid: # use the tor pid to help narrow connection results - tor_cmd = system.get_name_by_pid(tor_pid) + tor_cmd = system.name_by_pid(tor_pid)
if tor_cmd is None: tor_cmd = "tor" diff --git a/arm/graphing/bandwidth_stats.py b/arm/graphing/bandwidth_stats.py index 16cc349..dedde65 100644 --- a/arm/graphing/bandwidth_stats.py +++ b/arm/graphing/bandwidth_stats.py @@ -276,7 +276,7 @@ class BandwidthStats(graph_panel.GraphStats): missing_sec = time.time() - min(last_read_time, last_write_time)
if missing_sec: - msg += " (%s is missing)" % str_tools.get_time_label(missing_sec, 0, True) + msg += " (%s is missing)" % str_tools.time_label(missing_sec, 0, True)
log.notice(msg)
@@ -376,7 +376,7 @@ class BandwidthStats(graph_panel.GraphStats): stats[1] = "- %s" % self._get_avg_label(is_primary) stats[2] = ", %s" % self._get_total_label(is_primary)
- stats[0] = "%-14s" % ("%s/sec" % str_tools.get_size_label((self.last_primary if is_primary else self.last_secondary) * 1024, 1, False, CONFIG["features.graph.bw.transferInBytes"])) + stats[0] = "%-14s" % ("%s/sec" % str_tools.size_label((self.last_primary if is_primary else self.last_secondary) * 1024, 1, False, CONFIG["features.graph.bw.transferInBytes"]))
# drops label's components if there's not enough space
@@ -418,8 +418,8 @@ class BandwidthStats(graph_panel.GraphStats): label_in_bytes = CONFIG["features.graph.bw.transferInBytes"]
if bw_rate and bw_burst: - bw_rate_label = str_tools.get_size_label(bw_rate, 1, False, label_in_bytes) - bw_burst_label = str_tools.get_size_label(bw_burst, 1, False, label_in_bytes) + bw_rate_label = str_tools.size_label(bw_rate, 1, False, label_in_bytes) + bw_burst_label = str_tools.size_label(bw_burst, 1, False, label_in_bytes)
# if both are using rounded values then strip off the ".0" decimal
@@ -435,9 +435,9 @@ class BandwidthStats(graph_panel.GraphStats): # if there isn't yet enough bandwidth measurements).
if bw_observed and (not bw_measured or bw_measured == bw_observed): - stats.append("observed: %s/s" % str_tools.get_size_label(bw_observed, 1, False, label_in_bytes)) + stats.append("observed: %s/s" % str_tools.size_label(bw_observed, 1, False, label_in_bytes)) elif bw_measured: - stats.append("measured: %s/s" % str_tools.get_size_label(bw_measured, 1, False, label_in_bytes)) + stats.append("measured: %s/s" % str_tools.size_label(bw_measured, 1, False, label_in_bytes))
self._title_stats = stats
@@ -445,12 +445,12 @@ class BandwidthStats(graph_panel.GraphStats): total = self.primary_total if is_primary else self.secondary_total total += self.prepopulate_primary_total if is_primary else self.prepopulate_secondary_total
- return "avg: %s/sec" % str_tools.get_size_label((total / max(1, self.tick + self.prepopulate_ticks)) * 1024, 1, False, CONFIG["features.graph.bw.transferInBytes"]) + return "avg: %s/sec" % str_tools.size_label((total / max(1, self.tick + self.prepopulate_ticks)) * 1024, 1, False, CONFIG["features.graph.bw.transferInBytes"])
def _get_total_label(self, is_primary): total = self.primary_total if is_primary else self.secondary_total total += self.initial_primary_total if is_primary else self.initial_secondary_total - return "total: %s" % str_tools.get_size_label(total * 1024, 1) + return "total: %s" % str_tools.size_label(total * 1024, 1)
def _update_accounting_info(self): """ @@ -479,7 +479,7 @@ class BandwidthStats(graph_panel.GraphStats): sec = time.mktime(time.strptime(end_interval, "%Y-%m-%d %H:%M:%S")) - time.time() - tz_offset
if CONFIG["features.graph.bw.accounting.isTimeLong"]: - queried["reset_time"] = ", ".join(str_tools.get_time_labels(sec, True)) + queried["reset_time"] = ", ".join(str_tools.time_labels(sec, True)) else: days = sec / 86400 sec %= 86400 @@ -499,10 +499,10 @@ class BandwidthStats(graph_panel.GraphStats): read, written = int(used_comp[0]), int(used_comp[1]) read_left, written_left = int(left_comp[0]), int(left_comp[1])
- queried["read"] = str_tools.get_size_label(read) - queried["written"] = str_tools.get_size_label(written) - queried["read_limit"] = str_tools.get_size_label(read + read_left) - queried["writtenLimit"] = str_tools.get_size_label(written + written_left) + queried["read"] = str_tools.size_label(read) + queried["written"] = str_tools.size_label(written) + queried["read_limit"] = str_tools.size_label(read + read_left) + queried["writtenLimit"] = str_tools.size_label(written + written_left)
self.accounting_info = queried self.accounting_last_updated = time.time() diff --git a/arm/graphing/graph_panel.py b/arm/graphing/graph_panel.py index b54b8b8..c84813a 100644 --- a/arm/graphing/graph_panel.py +++ b/arm/graphing/graph_panel.py @@ -539,7 +539,7 @@ class GraphPanel(panel.Panel):
for i in range((graph_column - 4) / interval_spacing): loc = (i + 1) * interval_spacing - time_label = str_tools.get_time_label(loc * interval_sec, decimal_precision) + time_label = str_tools.time_label(loc * interval_sec, decimal_precision)
if not units_label: units_label = time_label[-1] diff --git a/arm/graphing/resource_stats.py b/arm/graphing/resource_stats.py index 856c2b7..1bbcfcb 100644 --- a/arm/graphing/resource_stats.py +++ b/arm/graphing/resource_stats.py @@ -38,8 +38,8 @@ class ResourceStats(graph_panel.GraphStats): else: # memory sizes are converted from MB to B before generating labels
- usage_label = str_tools.get_size_label(last_amount * 1048576, 1) - avg_label = str_tools.get_size_label(avg * 1048576, 1) + usage_label = str_tools.size_label(last_amount * 1048576, 1) + avg_label = str_tools.size_label(avg * 1048576, 1)
return "Memory (%s, avg: %s):" % (usage_label, avg_label)
diff --git a/arm/header_panel.py b/arm/header_panel.py index c0ab850..97a7fb3 100644 --- a/arm/header_panel.py +++ b/arm/header_panel.py @@ -247,7 +247,7 @@ class HeaderPanel(panel.Panel, threading.Thread): else: now = time.time()
- uptime = stem.util.str_tools.get_short_time_label(now - vals.start_time) + uptime = stem.util.str_tools.short_time_label(now - vals.start_time) else: uptime = ''
@@ -443,7 +443,7 @@ class Sampling(object): self.version_color = CONFIG['attr.version_status_colors'].get(self.version_status, 'white')
self.pid = pid if pid else '' - self.start_time = stem.util.system.get_start_time(pid) + self.start_time = stem.util.system.start_time(pid) self.fd_limit = int(fd_limit) if fd_limit.isdigit() else None
try: @@ -453,7 +453,7 @@ class Sampling(object):
self.tor_cpu = '%0.1f' % (100 * tor_resources.cpu_sample) self.arm_cpu = '%0.1f' % (100 * self._get_cpu_percentage(last_sampling)) - self.memory = stem.util.str_tools.get_size_label(tor_resources.memory_bytes) if tor_resources.memory_bytes > 0 else 0 + self.memory = stem.util.str_tools.size_label(tor_resources.memory_bytes) if tor_resources.memory_bytes > 0 else 0 self.memory_percent = '%0.1f' % (100 * tor_resources.memory_percent) self.hostname = uname_vals[1] self.platform = '%s %s' % (uname_vals[0], uname_vals[2]) # [platform name] [version] diff --git a/arm/starter.py b/arm/starter.py index ea8e17b..fbc9256 100644 --- a/arm/starter.py +++ b/arm/starter.py @@ -203,7 +203,7 @@ def _setup_freebsd_chroot(controller, config): """
if not config.get('tor.chroot', None) and platform.system() == 'FreeBSD': - jail_chroot = stem.util.system.get_bsd_jail_path(controller.get_pid(0)) + jail_chroot = stem.util.system.bsd_jail_path(controller.get_pid(0))
if jail_chroot and os.path.exists(jail_chroot): log.info('setup.set_freebsd_chroot', path = jail_chroot) diff --git a/arm/util/tor_config.py b/arm/util/tor_config.py index 32d0b07..bec1466 100644 --- a/arm/util/tor_config.py +++ b/arm/util/tor_config.py @@ -428,7 +428,7 @@ def get_config_location(): raise IOError("unable to query the torrc location")
try: - tor_cwd = system.get_cwd(tor_pid) + tor_cwd = system.cwd(tor_pid) return tor_prefix + system.expand_path(config_location, tor_cwd) except IOError as exc: raise IOError("querying tor's pwd failed because %s" % exc) @@ -736,9 +736,9 @@ def validate(contents = None): display_values = tor_values
if value_type == ValueType.SIZE: - display_values = [str_tools.get_size_label(int(val)) for val in tor_values] + display_values = [str_tools.size_label(int(val)) for val in tor_values] elif value_type == ValueType.TIME: - display_values = [str_tools.get_time_label(int(val)) for val in tor_values] + display_values = [str_tools.time_label(int(val)) for val in tor_values]
issues_found.append((line_number, ValidationError.MISMATCH, ", ".join(display_values)))
diff --git a/arm/util/tracker.py b/arm/util/tracker.py index 224c99c..b9246a4 100644 --- a/arm/util/tracker.py +++ b/arm/util/tracker.py @@ -395,7 +395,7 @@ class Daemon(threading.Thread): with self._process_lock: if not self._halt and event_type in (State.INIT, State.RESET): tor_pid = controller.get_pid(None) - tor_cmd = system.get_name_by_pid(tor_pid) if tor_pid else None + tor_cmd = system.name_by_pid(tor_pid) if tor_pid else None
self._process_pid = tor_pid self._process_name = tor_cmd if tor_cmd else 'tor' @@ -418,7 +418,7 @@ class ConnectionTracker(Daemon): super(ConnectionTracker, self).__init__(rate)
self._connections = [] - self._resolvers = connection.get_system_resolvers() + self._resolvers = connection.system_resolvers() self._custom_resolver = None
# Number of times in a row we've either failed with our current resolver or diff --git a/run_tests.py b/run_tests.py index c7482d3..9ac8765 100755 --- a/run_tests.py +++ b/run_tests.py @@ -44,14 +44,14 @@ def main(): static_check_issues = {}
if stem.util.test_tools.is_pyflakes_available(): - pyflakes_issues = stem.util.test_tools.get_pyflakes_issues(SRC_PATHS) + pyflakes_issues = stem.util.test_tools.pyflakes_issues(SRC_PATHS)
for path, issues in pyflakes_issues.items(): for issue in issues: static_check_issues.setdefault(path, []).append(issue)
if stem.util.test_tools.is_pep8_available(): - pep8_issues = stem.util.test_tools.get_stylistic_issues( + pep8_issues = stem.util.test_tools.stylistic_issues( SRC_PATHS, check_two_space_indents = True, check_newlines = True,
tor-commits@lists.torproject.org