![]() ![]() > subprocess.check_call("exit 1", shell=True) The CalledProcessError object will have the return code in the returncode attribute.Įxamples: > subprocess.check_call() If the return code was zero then return, otherwise raise CalledProcessError. subprocess.check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False) Use Popen with the communicate() method when you need pipes. > subprocess.call("exit 1", shell=True)ĭo not use stdout=PIPE or stderr=PIPE with this function as that can deadlock based on the child process output volume. The full function signature is the same as that of the Popen constructor - this functions passes all supplied arguments directly through to that interface.Įxamples: > subprocess.call() The arguments shown above are merely the most common ones, described below in Frequently Used Arguments (hence the slightly odd notation in the abbreviated signature). Wait for command to complete, then return the returncode attribute. subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False) For more advanced use cases when these do not meet your needs, use the underlying Popen interface. The recommended way to launch subprocesses is to use the following convenience functions. PEP 324 – PEP proposing the subprocess module 1. ![]() It is a drop in replacement with better behavior in many situations. POSIX users (Linux, BSD, etc.) are strongly encouraged to install and use the much more recent subprocess32 module instead of the version included with python 2.7. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |