commit 7178c5cb0a831d217c969ad38453dfdc85630983 Author: Damian Johnson atagar@torproject.org Date: Wed May 9 09:27:16 2012 -0700
Renaming read/write_history to read/write_history_line
The 'read_history' variable name was a bit vague, and generally the attribute isn't useful unlike its read_history_* counterparts. Renaming the variables to make it clear that read_history_line is the raw content for the read-history line. --- stem/descriptor/extrainfo_descriptor.py | 12 ++++++------ stem/descriptor/server_descriptor.py | 12 ++++++------ test/integ/descriptor/extrainfo_descriptor.py | 4 ++-- test/integ/descriptor/server_descriptor.py | 8 ++++---- test/unit/descriptor/server_descriptor.py | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py index 2ea8829..1def09c 100644 --- a/stem/descriptor/extrainfo_descriptor.py +++ b/stem/descriptor/extrainfo_descriptor.py @@ -145,12 +145,12 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor): geoip_db_digest (str) - sha1 of geoIP database file signature (str) - signature for this extrainfo descriptor (*)
- read_history (str) - read-history line, always unset + read_history_line (str) - bytes read for relayed traffic read_history_end (datetime.datetime) - end of the sampling interval read_history_interval (int) - seconds per interval read_history_values (list) - bytes read during each interval (*)
- write_history (str) - write-history line, always unset + write_history_line (str) - bytes written for relayed traffic write_history_end (datetime.datetime) - end of the sampling interval write_history_interval (int) - seconds per interval write_history_values (list) - bytes written during each interval (*) @@ -185,12 +185,12 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor): self.geoip_db_digest = None self.signature = None
- self.read_history = None + self.read_history_line = None self.read_history_end = None self.read_history_interval = None self.read_history_values = []
- self.write_history = None + self.write_history_line = None self.write_history_end = None self.write_history_interval = None self.write_history_values = [] @@ -276,12 +276,12 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor): raise ValueError("%s line has non-numeric values: %s" % (keyword, line))
if keyword == "read-history": - self.read_history = value + self.read_history_line = value self.read_history_end = timestamp self.read_history_interval = interval self.read_history_values = history_values else: - self.write_history = value + self.write_history_line = value self.write_history_end = timestamp self.write_history_interval = interval self.write_history_values = history_values diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py index 2a9d72f..80f1538 100644 --- a/stem/descriptor/server_descriptor.py +++ b/stem/descriptor/server_descriptor.py @@ -167,12 +167,12 @@ class ServerDescriptor(stem.descriptor.Descriptor): observed_bandwidth (int) - estimated capacity of the relay based on usage in bytes/s (*) eventdns (bool) - (deprecated) always unset (*)
- read_history (str) - (deprecated) read-history line, always unset + read_history_line (str) - (deprecated) bytes read for relayed traffic read_history_end (datetime.datetime) - (deprecated) end of the sampling interval read_history_interval (int) - (deprecated) seconds per interval read_history_values (list) - (deprecated) bytes read during each interval (*)
- write_history (str) - (deprecated) write-history line, always unset + write_history_line (str) - (deprecated) bytes written for relayed traffic write_history_end (datetime.datetime) - (deprecated) end of the sampling interval write_history_interval (int) - (deprecated) seconds per interval write_history_values (list) - (deprecated) bytes written during each interval (*) @@ -227,12 +227,12 @@ class ServerDescriptor(stem.descriptor.Descriptor): self.observed_bandwidth = None self.eventdns = True
- self.read_history = None + self.read_history_line = None self.read_history_end = None self.read_history_interval = None self.read_history_values = []
- self.write_history = None + self.write_history_line = None self.write_history_end = None self.write_history_interval = None self.write_history_values = [] @@ -481,12 +481,12 @@ class ServerDescriptor(stem.descriptor.Descriptor): raise ValueError("%s line has non-numeric values: %s" % (keyword, line))
if keyword == "read-history": - self.read_history = value + self.read_history_line = value self.read_history_end = timestamp self.read_history_interval = interval self.read_history_values = history_values else: - self.write_history = value + self.write_history_line = value self.write_history_end = timestamp self.write_history_interval = interval self.write_history_values = history_values diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py index d62a164..51af571 100644 --- a/test/integ/descriptor/extrainfo_descriptor.py +++ b/test/integ/descriptor/extrainfo_descriptor.py @@ -47,13 +47,13 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw # the initial contents for the line and parsed values.
read_start = "2012-05-05 17:02:45 (900 s) 3309568,9216,41984" - self.assertTrue(desc.read_history.startswith(read_start)) + self.assertTrue(desc.read_history_line.startswith(read_start))
read_values_start = [3309568, 9216, 41984, 27648, 123904] self.assertEquals(read_values_start, desc.read_history_values[:5])
write_start = "2012-05-05 17:02:45 (900 s) 1082368,19456,50176,272384" - self.assertTrue(desc.write_history.startswith(write_start)) + self.assertTrue(desc.write_history_line.startswith(write_start))
write_values_start = [1082368, 19456, 50176, 272384, 485376] self.assertEquals(write_values_start, desc.write_history_values[:5]) diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py index 57f6879..945d147 100644 --- a/test/integ/descriptor/server_descriptor.py +++ b/test/integ/descriptor/server_descriptor.py @@ -134,13 +134,13 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4= # the initial contents for the line and parsed values.
read_start = "2005-12-16 18:00:48 (900 s) 20774,489973,510022" - self.assertTrue(desc.read_history.startswith(read_start)) + self.assertTrue(desc.read_history_line.startswith(read_start))
read_values_start = [20774, 489973, 510022, 511163, 20949] self.assertEquals(read_values_start, desc.read_history_values[:5])
write_start = "2005-12-16 18:00:48 (900 s) 81,8848,8927,8927" - self.assertTrue(desc.write_history.startswith(write_start)) + self.assertTrue(desc.write_history_line.startswith(write_start))
write_values_start = [81, 8848, 8927, 8927, 83, 8848, 8931, 8929, 81, 8846] self.assertEquals(write_values_start, desc.write_history_values[:10]) @@ -164,8 +164,8 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4= with open(descriptor_path) as descriptor_file: for desc in stem.descriptor.server_descriptor.parse_file(descriptor_file): # the following attributes should be deprecated, and not appear in the wild - self.assertEquals(None, desc.read_history) - self.assertEquals(None, desc.write_history) + self.assertEquals(None, desc.read_history_line) + self.assertEquals(None, desc.write_history_line) self.assertEquals(True, desc.eventdns) self.assertEquals(0, desc.socks_port)
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py index e3b2ec6..63fd89d 100644 --- a/test/unit/descriptor/server_descriptor.py +++ b/test/unit/descriptor/server_descriptor.py @@ -235,10 +235,10 @@ class TestServerDescriptor(unittest.TestCase): desc = RelayDescriptor(desc_text)
if field == "read-history": - attr = (desc.read_history, desc.read_history_end, + attr = (desc.read_history_line, desc.read_history_end, desc.read_history_interval, desc.read_history_values) else: - attr = (desc.write_history, desc.write_history_end, + attr = (desc.write_history_line, desc.write_history_end, desc.write_history_interval, desc.write_history_values)
expected_end = datetime.datetime(2005, 12, 16, 18, 0, 48) @@ -257,7 +257,7 @@ class TestServerDescriptor(unittest.TestCase): value = "2005-12-17 01:23:11 (900 s) " desc_text = _make_descriptor({"opt read-history": value}) desc = RelayDescriptor(desc_text) - self.assertEquals(value, desc.read_history) + self.assertEquals(value, desc.read_history_line) self.assertEquals(datetime.datetime(2005, 12, 17, 1, 23, 11), desc.read_history_end) self.assertEquals(900, desc.read_history_interval) self.assertEquals([], desc.read_history_values)
tor-commits@lists.torproject.org