add doc for cmd.execute

This commit is contained in:
Prodesire 2017-11-10 22:28:44 +08:00
parent b33a3dfc13
commit 057edbf43d
2 changed files with 17 additions and 0 deletions

16
docs/cmd.rst Normal file
View File

@ -0,0 +1,16 @@
Cmd
-------
.. function:: pydu.cmd.execute(cmd, wait=True, shell=True)
Execute cmd based on ``subprocess.Popen``.
If ``wait`` is True, ``execute`` will return the tuple of ``(returncode, stdout)``.
Note, ``stderr`` is redirected to ``stdout``. If ``wait`` is False, ``execute``
will return object of ``Popen``.
``shell`` is same to parameter of ``Popen``.
>>> from pydu.cmd import execute
>>> execute('echo hello')
(0, b'hello\r\n') # Python 3
>>> execute('echo hello', wait=False)
<subprocess.Popen at 0x22e4010f9e8>

View File

@ -21,6 +21,7 @@ Content
:maxdepth: 1
archive
cmd
compat
dict
misc