[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Handling the server descriptor's uptime line



commit be8e245400161fe05a2899da9a003eefa8110989
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Mar 18 15:21:22 2012 -0700

    Handling the server descriptor's uptime line
---
 stem/descriptor/server_descriptor.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 4ba7acc..4ec4586 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -72,14 +72,15 @@ class ServerDescriptorV2(Descriptor):
     published (datetime.datetime) - time in GMT when the descriptor was generated (*)
     fingerprint (str)        - fourty hex digits that make up the relay's fingerprint
     hibernating (bool)       - flag to indicate if the relay was hibernating when published (*)
+    uptime (int)             - relay's uptime when published in seconds
     
     * required fields, others are left as None if undefined
   """
   
   nickname = address = or_port = socks_port = dir_port = None
   average_bandwidth = burst_bandwidth = observed_bandwidth = None
-  platform = tor_version = None
-  published = fingerprint = None
+  platform = tor_version = published = fingerprint = None
+  uptime = None
   hibernating = False
   
   def __init__(self, contents):
@@ -216,4 +217,10 @@ class ServerDescriptorV2(Descriptor):
           raise TypeError("Hibernating line had an invalid value, must be zero or one: %s" % value)
         
         self.hibernating = value == "1"
+      elif keyword == "uptime":
+        if not value.isdigit():
+          raise TypeError("Uptime line must have an integer value: %s" % value)
+        
+        self.uptime = int(value)
+          
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits