From 057edbf43d42d5948986fdc0da48a3b4d572e8ab Mon Sep 17 00:00:00 2001 From: Prodesire Date: Fri, 10 Nov 2017 22:28:44 +0800 Subject: [PATCH] add doc for cmd.execute --- docs/cmd.rst | 16 ++++++++++++++++ docs/index.rst | 1 + 2 files changed, 17 insertions(+) create mode 100644 docs/cmd.rst diff --git a/docs/cmd.rst b/docs/cmd.rst new file mode 100644 index 0000000..7ae322b --- /dev/null +++ b/docs/cmd.rst @@ -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) + diff --git a/docs/index.rst b/docs/index.rst index 75fbc58..9aa3c3c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,6 +21,7 @@ Content :maxdepth: 1 archive + cmd compat dict misc