commit 090e6f2da4c6583ce71e6e341b9ae28f01e75819 Author: Damian Johnson atagar@torproject.org Date: Sun Feb 2 16:09:39 2020 -0800
Drop connect_port and connect_socket_file
Removing a couple very old methods that are redundant with connect. --- stem/connection.py | 59 ---------------------------------------- test/integ/connection/connect.py | 48 ++------------------------------ 2 files changed, 2 insertions(+), 105 deletions(-)
diff --git a/stem/connection.py b/stem/connection.py index 140cff2e..e3032784 100644 --- a/stem/connection.py +++ b/stem/connection.py @@ -295,65 +295,6 @@ def connect(control_port = ('127.0.0.1', 'default'), control_socket = '/var/run/ return _connect_auth(control_connection, password, password_prompt, chroot_path, controller)
-def connect_port(address = '127.0.0.1', port = 9051, password = None, chroot_path = None, controller = stem.control.Controller): - """ - Convenience function for quickly getting a control connection. This is very - handy for debugging or CLI setup, handling setup and prompting for a password - if necessary (and none is provided). If any issues arise this prints a - description of the problem and returns **None**. - - .. deprecated:: 1.2.0 - Use :func:`~stem.connection.connect` instead. - - :param str address: ip address of the controller - :param int port: port number of the controller - :param str password: passphrase to authenticate to the socket - :param str chroot_path: path prefix if in a chroot environment - :param Class controller: :class:`~stem.control.BaseController` subclass to be - returned, this provides a :class:`~stem.socket.ControlSocket` if **None** - - :returns: authenticated control connection, the type based on the controller argument - """ - - try: - control_port = stem.socket.ControlPort(address, port) - except stem.SocketError as exc: - print(exc) - return None - - return _connect_auth(control_port, password, True, chroot_path, controller) - - -def connect_socket_file(path = '/var/run/tor/control', password = None, chroot_path = None, controller = stem.control.Controller): - """ - Convenience function for quickly getting a control connection. For more - information see the :func:`~stem.connection.connect_port` function. - - In much the same vein as git porcelain commands, users should not rely on - details of how this works. Messages or details of this function's behavior - might change in the future. - - .. deprecated:: 1.2.0 - Use :func:`~stem.connection.connect` instead. - - :param str path: path where the control socket is located - :param str password: passphrase to authenticate to the socket - :param str chroot_path: path prefix if in a chroot environment - :param Class controller: :class:`~stem.control.BaseController` subclass to be - returned, this provides a :class:`~stem.socket.ControlSocket` if **None** - - :returns: authenticated control connection, the type based on the controller argument - """ - - try: - control_socket = stem.socket.ControlSocketFile(path) - except stem.SocketError as exc: - print(exc) - return None - - return _connect_auth(control_socket, password, True, chroot_path, controller) - - def _connect_auth(control_socket, password, password_prompt, chroot_path, controller): """ Helper for the connect_* functions that authenticates the socket and diff --git a/test/integ/connection/connect.py b/test/integ/connection/connect.py index 84b4a8fc..a271843f 100644 --- a/test/integ/connection/connect.py +++ b/test/integ/connection/connect.py @@ -34,50 +34,6 @@ class TestConnect(unittest.TestCase):
@test.require.controller @patch('sys.stdout', new_callable = io.StringIO) - def test_connect_port(self, stdout_mock): - """ - Basic sanity checks for the connect_port function. - """ - - runner = test.runner.get_runner() - - control_socket = stem.connection.connect_port( - port = test.runner.CONTROL_PORT, - password = test.runner.CONTROL_PASSWORD, - chroot_path = runner.get_chroot(), - controller = None) - - if test.runner.Torrc.PORT in runner.get_options(): - test.runner.exercise_controller(self, control_socket) - control_socket.close() - self.assertEqual('', stdout_mock.getvalue()) - else: - self.assertEqual(control_socket, None) - - @test.require.controller - @patch('sys.stdout', new_callable = io.StringIO) - def test_connect_socket_file(self, stdout_mock): - """ - Basic sanity checks for the connect_socket_file function. - """ - - runner = test.runner.get_runner() - - control_socket = stem.connection.connect_socket_file( - path = test.runner.CONTROL_SOCKET_PATH, - password = test.runner.CONTROL_PASSWORD, - chroot_path = runner.get_chroot(), - controller = None) - - if test.runner.Torrc.SOCKET in runner.get_options(): - test.runner.exercise_controller(self, control_socket) - control_socket.close() - self.assertEqual('', stdout_mock.getvalue()) - else: - self.assertEqual(control_socket, None) - - @test.require.controller - @patch('sys.stdout', new_callable = io.StringIO) def test_connect_to_socks_port(self, stdout_mock): """ Common user gotcha is connecting to the SocksPort or ORPort rather than the @@ -87,8 +43,8 @@ class TestConnect(unittest.TestCase):
runner = test.runner.get_runner()
- control_socket = stem.connection.connect_port( - port = test.runner.SOCKS_PORT, + control_socket = stem.connection.connect( + control_port = ('127.0.0.1', test.runner.SOCKS_PORT), chroot_path = runner.get_chroot(), controller = None)