-
Damian Johnson authored
Some platforms append trailing whitespace to the output of the 'ss' command. Caught thanks to toralf... https://github.com/torproject/stem/issues/46 Determined the problem by running the following against toralf's output... from stem.util.connection import Resolver, get_connections from unittest.mock import patch with open('ss-nptu.log') as ss_file: ss_output = ss_file.read() with patch('stem.util.system.call') as call_mock: call_mock.return_value = ss_output.split('\n') print('parsed %i connections' % len(get_connections(Resolver.SS, process_pid = 2238, process_name = 'tor'))) Before: % python3.7 demo.py Traceback (most recent call last): File "demo.py", line 12, in <module> print('parsed %i connections' % len(get_connections(Resolver.SS, process_pid = 2238, process_name = 'tor'))) File "/home/atagar/Desktop/stem/stem/util/connection.py", line 333, in get_connections raise OSError('No results found using: %s' % resolver_command) OSError: No results found using: ss -nptu After: % python3.7 demo.py parsed 8114 connections
8a00dcb0