从python调用yeoman生成器?

从python调用yeoman生成器?,python,django,yeoman,popen,Python,Django,Yeoman,Popen,我需要在我一直在开发的Web应用程序中通过python调用这个生成器。最初,我是通过管道向发电机发送“是”,但我需要对第一个选项说“否” yes | yo angular --no-insight 现在我将一个文件的输出发送到生成器,让它输入 cat input.txt | yo angular --no-insight input.txt n y y 这很好,但我还需要存储日志,以便将输出重定向到out.txt cat input.txt | yo angular --no-insigh

我需要在我一直在开发的Web应用程序中通过python调用这个生成器。最初,我是通过管道向发电机发送“是”,但我需要对第一个选项说“否”

yes | yo angular --no-insight
现在我将一个文件的输出发送到生成器,让它输入

cat input.txt | yo angular --no-insight
input.txt

n
y
y
这很好,但我还需要存储日志,以便将输出重定向到out.txt

cat input.txt | yo angular --no-insight > out.txt
这就是问题所在,正如我所预料的,第一个提示被回答为“否”,然后一切都停止了

我需要一种编程运行生成器的方法,我认为使用适配器将是解决方案,但似乎绝对没有编写适配器的文档

我应该做什么来适应我的用例

编辑:这是我已经用来运行命令的popen调用

        Popen("cat input.txt | yo angular --no-insight", shell=True).wait()
运行该命令的类在其自己的线程上,因此等待几分钟不是问题。不过,我可能会在将来的更新中删除该选项,以处理发电机出现任何问题时的超时情况。

您可以使用python的:


您也可以创建一个
Popen
对象到“yo angular--no insight”,然后写入stdin并从stdout读取。

如果从命令行运行
out.txt
会发生什么?(它工作吗?)如何在Python中运行该命令?(显示代码)同样的情况也会发生,第一个提示被回答为否,然后没有其他输入被传递。帖子已经更新,包括我的popen呼叫。你也尝试重定向stderr了吗?在bash:
&>out.txt
中,若要将子流程的输出重定向到文件,请改用
检查调用(cmd,stdout=file\u output)
。感谢您的评论,使用file\u output.write()解决方案得到了相同的结果,输入的第一行被传入,然后不再进行进一步的输入。我忘了提到我已经在使用子流程了。我将更多地使用Popens stdin和stdout重定向来实现这一点。
with open('out.txt', 'w') as file_output:
    file_output.write(subprocess.check_output('cat input.txt | yo angular --no-insight', shell=True))