unix_lang.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:zpy 作者: albertaleksieiev 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号