[or-cvs] r18875: {torctl} Change when we display warns relating to restriction issues (torctl/trunk/python/TorCtl)
mikeperry at seul.org
mikeperry at seul.org
Wed Mar 11 05:16:46 UTC 2009
Author: mikeperry
Date: 2009-03-11 01:16:45 -0400 (Wed, 11 Mar 2009)
New Revision: 18875
Modified:
torctl/trunk/python/TorCtl/PathSupport.py
torctl/trunk/python/TorCtl/TorCtl.py
Log:
Change when we display warns relating to restriction issues so
we don't spam the user with messages. Also workaround an ugly
exit condition Roger ran into.
Modified: torctl/trunk/python/TorCtl/PathSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/PathSupport.py 2009-03-11 05:09:25 UTC (rev 18874)
+++ torctl/trunk/python/TorCtl/PathSupport.py 2009-03-11 05:16:45 UTC (rev 18875)
@@ -173,8 +173,8 @@
"Rewind the generator to the 'beginning'"
self.routers = copy.copy(self.rstr_routers)
if not self.routers:
- plog("WARN", "No routers left after restrictions applied: "+str(self.rstr_list))
- raise NoNodesRemain()
+ plog("NOTICE", "No routers left after restrictions applied: "+str(self.rstr_list))
+ raise NoNodesRemain(str(self.rstr_list))
def rebuild(self, sorted_r=None):
""" Extra step to be performed when new routers are added or when
@@ -183,8 +183,8 @@
self.sorted_r = sorted_r
self.rstr_routers = filter(lambda r: self.rstr_list.r_is_ok(r), self.sorted_r)
if not self.rstr_routers:
- plog("WARN", "No routers left after restrictions applied: "+str(self.rstr_list))
- raise NoNodesRemain()
+ plog("NOTICE", "No routers left after restrictions applied: "+str(self.rstr_list))
+ raise NoNodesRemain(str(self.rstr_list))
def mark_chosen(self, r):
"""Mark a router as chosen: remove it from the list of routers
@@ -1086,16 +1086,14 @@
def new_consensus(self, consensus):
self.consensus = consensus
- if self.exit_id:
- self.set_exit(self.exit_id)
- if self.bad_restrictions:
- return
try:
self.path_selector.rebuild_gens(self.consensus.sorted_r)
+ if self.exit_id:
+ self.set_exit(self.exit_id)
except NoNodesRemain:
- traceback.print_exc()
- plog("WARN", "No viable nodes in consensus. Punting + performing reconfigure..")
- self.reconfigure()
+ plog("NOTICE", "No viable nodes in consensus for restrictions.")
+ # Punting + performing reconfigure..")
+ #self.reconfigure(consensus)
def set_target(self, ip, port):
# sets an exit policy, if bad, rasies exception..
@@ -1327,7 +1325,7 @@
# XXX: Dress this up a bit
self.last_exit = None
# Kill this stream
- plog("NOTICE", "Closing impossible stream "+str(stream.strm_id)+" ("+str(e)+")")
+ plog("WARN", "Closing impossible stream "+str(stream.strm_id)+" ("+str(e)+")")
try:
self.c.close_stream(stream.strm_id, "4") # END_STREAM_REASON_EXITPOLICY
except TorCtl.ErrorReply, e:
Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py 2009-03-11 05:09:25 UTC (rev 18874)
+++ torctl/trunk/python/TorCtl/TorCtl.py 2009-03-11 05:16:45 UTC (rev 18875)
@@ -431,9 +431,13 @@
except TorCtlClosed:
plog("NOTICE", "Tor closed control connection. Exiting event thread.")
return
- except:
+ except Exception,e:
if not self._closed:
- self._err(sys.exc_info())
+ if sys:
+ self._err(sys.exc_info())
+ else:
+ plog("NOTICE", "No sys left at exception shutdown: "+str(e))
+ self._err((e.__class__, e, None))
return
else:
isEvent = 0
More information about the tor-commits
mailing list