[tor-commits] [fallback-scripts/master] generate: Handle new exceptions added by stem

teor at torproject.org teor at torproject.org
Mon Jan 20 05:32:01 UTC 2020


commit 22ac1c66a920cb0b6b4181df4a32a3e842ecb250
Author: teor <teor at torproject.org>
Date:   Mon Dec 2 13:56:09 2019 +1000

    generate: Handle new exceptions added by stem
    
    But maintain compatibility with older stem versions.
    
    Part of 28863.
---
 generateFallbackDirLine.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/generateFallbackDirLine.py b/generateFallbackDirLine.py
index b856c93..2177e00 100755
--- a/generateFallbackDirLine.py
+++ b/generateFallbackDirLine.py
@@ -9,9 +9,18 @@
 import sys
 import urllib2
 
+import stem
 import stem.descriptor.remote
 import stem.util.tor_tools
 
+## Stem version compatibility
+try:
+  stem_DownloadFailed = stem.DownloadFailed
+except AttributeError:
+  class DummyException(BaseException):
+    pass
+  stem_DownloadFailed = DummyException
+
 if len(sys.argv) <= 1:
   print('Usage: %s fingerprint ...' % sys.argv[0])
   sys.exit(1)
@@ -29,6 +38,9 @@ for fingerprint in sys.argv[1:]:
       continue
     else:
       raise
+  except stem_DownloadFailed as exc:
+    print('# %s not found by stem' % fingerprint)
+    continue
 
   if not desc.dir_port:
     print("# %s needs a DirPort" % fingerprint)





More information about the tor-commits mailing list