[tor-bugs] #7784 [Stem]: add Controller.get_socks_port

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Jan 4 15:18:10 UTC 2013


#7784: add Controller.get_socks_port
----------------------------+-----------------------------------------------
    Reporter:  robinson     |       Owner:  atagar    
        Type:  enhancement  |      Status:  closed    
    Priority:  normal       |   Milestone:            
   Component:  Stem         |     Version:            
  Resolution:  implemented  |    Keywords:  controller
      Parent:               |      Points:            
Actualpoints:               |  
----------------------------+-----------------------------------------------

Comment(by robinson):

 Just to document "Also, remove the the space in the join so that there is
 only one parameter passed to the string substitution." better:

 I was getting an unhelpful error with the following code:

 {{{
 import stem.socket

 from stem import InvalidArguments
 from stem.control import Controller

 from test import mocking

 socket = stem.socket.ControlSocket()
 controller = Controller(socket)

 mocking.mock_method(Controller, "get_info",
 mocking.raise_exception(InvalidArguments))

 mocking.mock_method(Controller, "get_conf", mocking.return_for_args({
   ("SocksPort", "useless_second", "useless_third"): "9050",
   ("SocksListenAddress", "multiple=True"): ["127.0.0.1"]
 }, is_method = True))

 controller.get_socks_listeners()
 }}}

 Old error:

 {{{
 Traceback (most recent call last):
   File "./return_for_args-test.py", line 19, in <module>
     controller.get_socks_listeners()
   File "stem/control.py", line 1348, in get_socks_listeners
     socks_port = self.get_conf('SocksPort')
   File "test/mocking.py", line 360, in <lambda>
     mock_wrapper = lambda *args, **kwargs: mock_call(*args, **kwargs)
   File "test/mocking.py", line 261, in _return_value
     raise ValueError("Unrecognized argument sent for return_for_args().
 Got '%s' but we
 only recognize '%s'." % (arg_label, ",
 ".join(args_to_return_value.keys())))
 TypeError: sequence item 0: expected string, tuple found
 }}}

 I mistakenly believed this was due to spaces in the keys in
 args_to_return_value, but really is was the tuple-as-key did not work in
 the string substitution.  But, I over-corrected.  Damian's revision of my
 fix works and gives readable output.

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/7784#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list