我可以在Python中记录子过程吗?
我必须在python脚本内进行一些apt install
命令,并且可以使用子过程。但是问题是我看不到安装进度(错误,完成,没有启动,正在进行等)。有没有一种方法可以像Bash一样打印apt
日志?
I have to lanch some apt install
commands inside a Python script, and this is possible using the subprocess. But the problem is that I can't see the installation progress (error, completed, didn't start, ongoing etc.). Is there a way to print the apt
logs just like in bash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此示例。它使用popen的
stdout
使用iter()。由于您没有povide a代码,您如何调用APT GET我使用ping进行演示,但原理是相同的。Check out this example. It uses iter() over
stdout
from Popen. Since you didn't povide a code how do you call apt get I used ping for demo but the principle is the same.