~ubuntu-branches/ubuntu/trusty/pexpect/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/api/pexpect.rst

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio, Thomas Kluyver, Jakub Wilk, Jackson Doak, Andrew Starr-Bochicchio
  • Date: 2013-12-06 20:20:26 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131206202026-9k9oixbv7e8ke30q
Tags: 3.0-1
* Team upload.

[ Thomas Kluyver ]
* New upstream release. Closes: #729518
* Add packaging for Python 3.
* Use pybuild for packaging.

[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Jackson Doak ]
* Create debian/python3-pexpect.docs

[ Andrew Starr-Bochicchio ]
* Remove empty debian/patches dir.
* Move documentation and examples into a new python-pexpect-doc
  package. They are shared between the Python 2 and Python 3 packages,
  so there is no need to install them with both.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Core pexpect components
 
2
=======================
 
3
 
 
4
.. automodule:: pexpect
 
5
 
 
6
spawn class
 
7
-----------
 
8
 
 
9
.. autoclass:: spawn
 
10
 
 
11
   .. automethod:: __init__
 
12
   .. automethod:: expect
 
13
   .. automethod:: expect_exact
 
14
   .. automethod:: expect_list
 
15
   .. automethod:: compile_pattern_list
 
16
   .. automethod:: send
 
17
   .. automethod:: sendline
 
18
   .. automethod:: write
 
19
   .. automethod:: writelines
 
20
   .. automethod:: sendcontrol
 
21
   .. automethod:: sendeof
 
22
   .. automethod:: sendintr
 
23
   .. automethod:: read
 
24
   .. automethod:: readline
 
25
   .. automethod:: read_nonblocking
 
26
   .. automethod:: eof
 
27
   .. automethod:: interact
 
28
 
 
29
   .. attribute:: logfile
 
30
                  logfile_read
 
31
                  logfile_send
 
32
 
 
33
      Set these to a Python file object (or :data:`sys.stdout`) to log all
 
34
      communication, data read from the child process, or data sent to the child
 
35
      process.
 
36
 
 
37
      .. note::
 
38
 
 
39
         With a :class:`spawn` instance, the log files should be open for
 
40
         writing binary data. With a :class:`spawnu` instance, they should
 
41
         be open for writing unicode text.
 
42
 
 
43
Controlling the child process
 
44
`````````````````````````````
 
45
 
 
46
.. class:: spawn
 
47
 
 
48
   .. automethod:: kill
 
49
   .. automethod:: terminate
 
50
   .. automethod:: isalive
 
51
   .. automethod:: wait
 
52
   .. automethod:: close
 
53
   .. automethod:: getwinsize
 
54
   .. automethod:: setwinsize
 
55
   .. automethod:: getecho
 
56
   .. automethod:: setecho
 
57
   .. automethod:: waitnoecho
 
58
 
 
59
   .. attribute:: pid
 
60
 
 
61
      The process ID of the child process.
 
62
 
 
63
   .. attribute:: child_fd
 
64
 
 
65
      The file descriptor used to communicate with the child process.
 
66
 
 
67
.. _unicode:
 
68
 
 
69
Handling unicode
 
70
````````````````
 
71
 
 
72
For backwards compatibility, :class:`spawn` can handle some Unicode: its
 
73
send methods will encode arbitrary unicode as UTF-8 before sending it to the
 
74
child process, and its expect methods can accept ascii-only unicode strings.
 
75
However, for a proper unicode API to a subprocess, use this subclass:
 
76
 
 
77
.. autoclass:: spawnu
 
78
   :show-inheritance:
 
79
 
 
80
There is also a :func:`runu` function, the unicode counterpart to :func:`run`.
 
81
 
 
82
.. note::
 
83
 
 
84
   Unicode handling with pexpect works the same way on Python 2 and 3, despite
 
85
   the difference in names. I.e.:
 
86
 
 
87
   - :class:`spawn` works with ``str`` on Python 2, and :class:`bytes` on Python 3,
 
88
   - :class:`spawnu` works with ``unicode`` on Python 2, and :class:`str` on Python 3.
 
89
 
 
90
run function
 
91
------------
 
92
 
 
93
.. autofunction:: run
 
94
 
 
95
.. autofunction:: runu
 
96
 
 
97
Exceptions
 
98
----------
 
99
 
 
100
.. autoclass:: EOF
 
101
 
 
102
.. autoclass:: TIMEOUT
 
103
 
 
104
.. autoclass:: ExceptionPexpect
 
105
 
 
106
Utility functions
 
107
-----------------
 
108
 
 
109
.. autofunction:: which
 
110
 
 
111
.. autofunction:: split_command_line