[tor-commits] [stem/master] Added downloadable tutorial example for tutorial The Little Relay That Could

atagar at torproject.org atagar at torproject.org
Mon May 25 17:15:20 UTC 2015


commit 157ec5333dff4547b30c574339af1af3e9558d38
Author: Sambuddha Basu <sambuddhabasu1 at gmail.com>
Date:   Mon May 25 05:25:39 2015 +0400

    Added downloadable tutorial example for tutorial The Little Relay That Could
---
 docs/_static/example/the_little_relay_that_could.py |    9 +++++++++
 docs/tutorials/the_little_relay_that_could.rst      |   14 ++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/docs/_static/example/the_little_relay_that_could.py b/docs/_static/example/the_little_relay_that_could.py
new file mode 100644
index 0000000..88dd881
--- /dev/null
+++ b/docs/_static/example/the_little_relay_that_could.py
@@ -0,0 +1,9 @@
+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)
diff --git a/docs/tutorials/the_little_relay_that_could.rst b/docs/tutorials/the_little_relay_that_could.rst
index 63e4493..8c16512 100644
--- a/docs/tutorials/the_little_relay_that_could.rst
+++ b/docs/tutorials/the_little_relay_that_could.rst
@@ -47,17 +47,11 @@ many bytes Tor has sent and received since it started. Note that there are a
 unfamiliar with the '**with**' keyword then see `here
 <../faq.html#what-is-that-with-keyword-i-keep-seeing-in-the-tutorials>`_...
 
-::
-
-  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")
+.. literalinclude:: /_static/example/the_little_relay_that_could.py
+   :language: python
 
-    print "My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written)
+The above code snippet can be downloaded by clicking `here
+<../_static/example/the_little_relay_that_could.py>`_.
 
 ::
 





More information about the tor-commits mailing list