[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Parsing read/write-history lines in extrainfo descriptors
commit fa6d81cf69d5590f6bcb0ad94cf34a7b313f02c2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed May 9 08:09:00 2012 -0700
Parsing read/write-history lines in extrainfo descriptors
Copying the code for parsing from the server descriptors. I suspect that this
isn't yet exercised by the tests - I'm next gonna improve our integ tests then
check if this would be appropriate for a unit test too.
---
stem/descriptor/extrainfo_descriptor.py | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index ca34ca1..2ea8829 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -263,6 +263,31 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
except ValueError:
if validate:
raise ValueError("Published line's time wasn't parseable: %s" % line)
+ elif keyword in ("read-history", "write-history"):
+ try:
+ timestamp, interval, remainder = _parse_timestamp_and_interval(keyword, value)
+
+ try:
+ if remainder:
+ history_values = [int(entry) for entry in remainder.split(",")]
+ else:
+ history_values = []
+ except ValueError:
+ raise ValueError("%s line has non-numeric values: %s" % (keyword, line))
+
+ if keyword == "read-history":
+ self.read_history = 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_end = timestamp
+ self.write_history_interval = interval
+ self.write_history_values = history_values
+ except ValueError, exc:
+ if not validate: continue
+ else: raise exc
elif keyword == "router-signature":
if validate and not block_contents:
raise ValueError("Router signature line must be followed by a signature block: %s" % line)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits