【发布时间】:2015-03-16 16:22:23
【问题描述】:
请帮我从 Perforce 读取数据/文件。
我尝试使用以下代码使用此 python 脚本从 Perforce 读取文件。
相同的代码在 Python shell 中运行良好,即使在 pycharm 中逐步执行它也能完美运行。
# copy the file from the P4 to the local computer
def getp4file(outfile,errfile,path):
path = 'p4 print ' + path
with open(outfile, "wb") as out, open(errfile, "wb") as err:
subprocess.Popen(path, stdout=out, stderr=err)
out.close()
err.close()
return
getp4file('config.txt', 'err.txt', 'path_of_the_file')
【问题讨论】:
-
是否有任何内容被打印到 config.txt 或 err.txt 中?
-
您的代码对我来说可以正常工作(请注意,您对
subprocess.Popen的使用取决于平台;最好使用subprocess.Popen(['p4', 'print', path], stdout=out, stderr=err)),因此您需要提供更多详细信息,特别是err.txt的内容。 (path_of_the_file是仓库路径吗?相对路径?绝对路径?) -
刚刚添加了延迟并且一切正常。返回语句前延迟 5 秒
标签: python python-3.x perforce perforce-client-spec perforce-integrate