def create_proc(self,line, env = None, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None):
"""
Create subprocess Popen
https://docs.python.org/3/library/subprocess.html
:param line: line to evaluate
:param env: Env variable
:param stdin: stdin type
:param stdout: stdout type
:param stderr: stderr type
read more about types
https://docs.python.org/3/library/subprocess.html#subprocess.DEVNULL
:return: Popen
>>> UnixLang().create_proc('echo "DEVNULL|PIPE|STDOUT"', stdout=subprocess.PIPE).communicate()[0].decode().strip()
'DEVNULL|PIPE|STDOUT'
"""
proc = subprocess.Popen([line],
stdin=stdin,
stdout=stdout,
stderr=stderr,
shell=True,
env=env,
cwd=self.current_dir)
return proc
评论列表
文章目录