I am trying to control tor on ubuntu linux using python's stem library as instructed on tor's website. However, when I ran the suggested python code
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate() # provide the password here if you set one
bytes_read = controller.get_info("traffic/read")
bytes_written = controller.get_info("traffic/written")
print "My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written)
I get the error:
Traceback (most recent call last):
File "littleRelay.py", line 5, in module
bytes_read = controller.get_info("traffic/read")
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 852, in get_info
raise exc
stem.InvalidArguments: GETINFO request contained unrecognized keywords: traffic/read
So how can I get Tor relay info via python+stem on linux? I think Tor is running fine because I started tor from the terminal and it says
[notice] Tor has successfully opened a circuit. Looks like client functionality is working.
[notice] Bootstrapped 100%: Done.
Furthermore, when I run the above python code, the terminal says
[notice] New control connection opened.
P.S. I have also tried the code on a windows pc and it worked. I'm really puzzled now.