如何使用自定义工具在perforce客户端p4v的日志窗口中输出
我们正在用 python 开发 perforce 自定义工具,并在脚本执行期间输出消息。它显示在 p4win 中,但我们主要使用 p4v 并且输出不会显示在日志窗口中。
有没有办法在此处或任何其他窗格中输出,而无需在终端窗口中运行该工具?
We're developing perforce custom tools in python and we're outputting messages during the script execution. It shows up in p4win but we're mainly using p4v and the output doesn't show up in the log window.
Is there a way to output there or in any other pane without resorting to run the tool in a terminal window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 Python 将其输出定向到管道而不是直接定向到终端时,它默认缓冲其输出。我认为您可以通过在调用 Python 时传递“-u”参数(例如 python -u myscript.py arg1 arg2 )来告诉它不要缓冲,或者调用
sys.stdout.flush()
贯穿整个脚本,只要您希望它确保输出已到达 P4V。另请参阅:
http://kb. perforce.com/article/914/sending-script-output-to-p4vs-custom-tool-terminal
(看起来这个问题是在您在 Stack Overflow 上提问后提出并回答的。抱歉,如果您是已经很清楚了。)
When Python is directing its output to a pipe rather than straight to a terminal, it buffers its output by default. I think you can work around this by either passing the "-u" parameter when invoking Python (e.g.,
python -u myscript.py arg1 arg2
) to tell it not to buffer, or by callingsys.stdout.flush()
throughout your script any time you want it to make sure that the output has made it to P4V.See also:
http://kb.perforce.com/article/914/sending-script-output-to-p4vs-custom-tool-terminal
(It looks like that question was asked and answered after you asked here on Stack Overflow. Sorry if you're already well aware of it.)