tools.py 文件源码

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

项目:EasyClangComplete 作者: niosus 项目源码 文件源码
def run_command(command, shell=True, cwd=path.curdir, env=environ):
        """Run a generic command in a subprocess.

        Args:
            command (str): command to run

        Returns:
            str: raw command output
        """
        try:
            stdin = None
            startupinfo = None
            if isinstance(command, list):
                command = subprocess.list2cmdline(command)
                log.debug("running command: \n%s", command)
            if sublime.platform() == "windows":
                # Don't let console window pop-up briefly.
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                startupinfo.wShowWindow = subprocess.SW_HIDE
                stdin = subprocess.PIPE
            output = subprocess.check_output(command,
                                             stdin=stdin,
                                             stderr=subprocess.STDOUT,
                                             shell=shell,
                                             cwd=cwd,
                                             env=env,
                                             startupinfo=startupinfo)
            output_text = ''.join(map(chr, output))
        except subprocess.CalledProcessError as e:
            output_text = e.output.decode("utf-8")
            log.debug("command finished with code: %s", e.returncode)
            log.debug("command output: \n%s", output_text)
        return output_text
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号