[or-cvs] r19596: {torctl} Support new verbose names. And by support, I mean parse and (torctl/trunk/python/TorCtl)

mikeperry at seul.org mikeperry at seul.org
Sat May 30 10:10:08 UTC 2009


Author: mikeperry
Date: 2009-05-30 06:10:08 -0400 (Sat, 30 May 2009)
New Revision: 19596

Modified:
   torctl/trunk/python/TorCtl/TorCtl.py
Log:

Support new verbose names. And by support, I mean parse and
then disregard. Turns out I really don't care what these
things choose to call themselves at the time of the event.
That's what the consensus is for.



Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py	2009-05-30 10:07:44 UTC (rev 19595)
+++ torctl/trunk/python/TorCtl/TorCtl.py	2009-05-30 10:10:08 UTC (rev 19596)
@@ -937,13 +937,13 @@
   nsgroups.pop(0)
   nslist = []
   for nsline in nsgroups:
-    m = re.search(r"^s((?:\s\S*)+)", nsline, re.M)
+    m = re.search(r"^s((?:[ ]\S*)+)", nsline, re.M)
     flags = m.groups()
     flags = flags[0].strip().split(" ")
     m = re.match(r"(\S+)\s(\S+)\s(\S+)\s(\S+\s\S+)\s(\S+)\s(\d+)\s(\d+)", nsline)    
     w = re.search(r"^w Bandwidth=(\d+)", nsline, re.M)
     if w:
-      nslist.append(NetworkStatus(*(m.groups() + (flags,) + int(w.group(0)))))
+      nslist.append(NetworkStatus(*(m.groups() + (flags,) + (int(w.group(1)),))))
     else:
       nslist.append(NetworkStatus(*(m.groups() + (flags,))))
   return nslist
@@ -1079,7 +1079,10 @@
           purpose = ""
           path=[]
         else:
-          path = path.strip().split(",")
+          path_verb = path.strip().split(",")
+          path = []
+          for p in path_verb:
+            path.append(p.replace("~", "=").split("=")[0])
       else:
         path = []
 
@@ -1142,7 +1145,11 @@
     elif evtype in ("DEBUG", "INFO", "NOTICE", "WARN", "ERR"):
       event = LogEvent(evtype, body)
     elif evtype == "NEWDESC":
-      event = NewDescEvent(evtype, body.split(" "))
+      ids_verb = body.split(" ")
+      ids = []
+      for i in ids_verb:
+        ids.append(i.replace("~", "=").split("=")[0])
+      event = NewDescEvent(evtype, ids)
     elif evtype == "ADDRMAP":
       # TODO: Also parse errors and GMTExpiry
       m = re.match(r'(\S+)\s+(\S+)\s+(\"[^"]+\"|\w+)', body)



More information about the tor-commits mailing list