Cmd¶
-
pydu.cmd.
run
(cmd, wait=True, shell=True)¶ Run cmd based on
subprocess.Popen
. Ifwait
is True,run
will return the tuple of(returncode, stdout)
. Note,stderr
is redirected tostdout
. Ifwait
is False,run
will return object ofPopen
.shell
is same to parameter ofPopen
.>>> from pydu.cmd import run >>> run('echo hello') (0, b'hello\r\n') # Python 3 >>> run('echo hello', wait=False) <subprocess.Popen at 0x22e4010f9e8>
-
pydu.cmd.
cmdline_argv
()¶ Get command line argv of self python process. On Windows when using Python 2,
cmdline_argv
is implemented by usingshell32.GetCommandLineArgvW
to get sys.argv as a list of Unicode strings. On other system or using Python 3,cmdline_argv
is same tosys.argv
.There is an example on PyCharm Python Console:
>>> from pydu.cmd import cmdline_argv >>> cmdline_argv() ['/Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py', '61253', '61254']