Skip to content

Commit 9bb3dac

Browse files
committed
docs: break out install_app.py and fix API use.
1 parent 86337c4 commit 9bb3dac

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

docs/changelog.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ Core Library
136136
`closed` flag, preventing historical bugs where a double close could destroy
137137
descriptors belonging to unrelated streams.
138138

139+
* `#606 <https://github.com/dw/mitogen/issues/606>`_: fix example code on the
140+
documentation front page.
141+
139142
* `a5536c35 <https://github.com/dw/mitogen/commit/a5536c35>`_: avoid quadratic
140143
buffer management when logging lines received from a child's redirected
141144
standard IO.
@@ -150,11 +153,12 @@ bug reports, testing, features and fixes in this release contributed by
150153
`Anton Markelov <https://github.com/strangeman>`_,
151154
`Nigel Metheringham <https://github.com/nigelm>`_,
152155
`Orion Poplawski <https://github.com/opoplawski>`_,
156+
`Pieter Voet <https://github.com/pietervoet/>`_,
157+
`Stefane Fermigier <https://github.com/sfermigier>`_,
153158
`Szabó Dániel Ernő <https://github.com/r3ap3rpy>`_,
154159
`Ulrich Schreiner <https://github.com/ulrichSchreiner>`_,
155160
`Yuki Nishida <https://github.com/yuki-nishida-exa>`_,
156-
`@ghp-rr <https://github.com/ghp-rr>`_,
157-
`Pieter Voet <https://github.com/pietervoet/>`_, and
161+
`@ghp-rr <https://github.com/ghp-rr>`_, and
158162
`@rizzly <https://github.com/rizzly>`_.
159163

160164

docs/index.rst

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -329,36 +329,7 @@ External contexts are configured such that any attempt to execute a function
329329
from the main Python script will correctly cause that script to be imported as
330330
usual into the slave process.
331331

332-
.. code-block:: python
333-
334-
#!/usr/bin/env python
335-
"""
336-
Install our application on a remote machine.
337-
338-
Usage:
339-
install_app.py <hostname>
340-
341-
Where:
342-
<hostname> Hostname to install to.
343-
"""
344-
import os
345-
import sys
346-
347-
import mitogen
348-
349-
350-
def install_app():
351-
os.system('tar zxvf my_app.tar.gz')
352-
353-
354-
@mitogen.main()
355-
def main(broker):
356-
if len(sys.argv) != 2:
357-
print(__doc__)
358-
sys.exit(1)
359-
360-
context = mitogen.ssh.connect(broker, sys.argv[1])
361-
context.call(install_app)
332+
.. literalinclude:: ../examples/install_app.py
362333

363334

364335
Event-driven IO

examples/install_app.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
"""
3+
Install our application on a remote machine.
4+
5+
Usage:
6+
install_app.py <hostname>
7+
8+
Where:
9+
<hostname> Hostname to install to.
10+
"""
11+
import os
12+
import sys
13+
14+
import mitogen
15+
16+
17+
def install_app():
18+
os.system('tar zxvf my_app.tar.gz')
19+
20+
21+
@mitogen.main()
22+
def main(router):
23+
if len(sys.argv) != 2:
24+
print(__doc__)
25+
sys.exit(1)
26+
27+
context = router.ssh(hostname=sys.argv[1])
28+
context.call(install_app)

0 commit comments

Comments
 (0)