Ticket #10411: 0001-Added-downloadable-tutorial-example-for-tutorial-The.patch

File 0001-Added-downloadable-tutorial-example-for-tutorial-The.patch, 2.2 KB (added by sambuddhabasu, 4 years ago)

Downloadable tutorial example for tutorial The Little Relay that Could

  • new file docs/_static/example/the_little_relay_that_could.py

    From 157ec5333dff4547b30c574339af1af3e9558d38 Mon Sep 17 00:00:00 2001
    From: Sambuddha Basu <sambuddhabasu1@gmail.com>
    Date: Mon, 25 May 2015 05:25:39 +0400
    Subject: [PATCH] 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(-)
     create mode 100644 docs/_static/example/the_little_relay_that_could.py
    
    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
    - +  
     1from stem.control import Controller
     2
     3with Controller.from_port(port = 9051) as controller:
     4  controller.authenticate()  # provide the password here if you set one
     5
     6  bytes_read = controller.get_info("traffic/read")
     7  bytes_written = controller.get_info("traffic/written")
     8
     9  print "My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written)
  • docs/tutorials/the_little_relay_that_could.rst

    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 b many bytes Tor has sent and received since it started. Note that there are a 
    4747unfamiliar with the '**with**' keyword then see `here
    4848<../faq.html#what-is-that-with-keyword-i-keep-seeing-in-the-tutorials>`_...
    4949
    50 ::
    51 
    52   from stem.control import Controller
    53  
    54   with Controller.from_port(port = 9051) as controller:
    55     controller.authenticate()  # provide the password here if you set one
    56 
    57     bytes_read = controller.get_info("traffic/read")
    58     bytes_written = controller.get_info("traffic/written")
     50.. literalinclude:: /_static/example/the_little_relay_that_could.py
     51   :language: python
    5952
    60     print "My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written)
     53The above code snippet can be downloaded by clicking `here
     54<../_static/example/the_little_relay_that_could.py>`_.
    6155
    6256::
    6357