【问题标题】:Not able to read data from Perforce using python script无法使用 python 脚本从 Perforce 读取数据
【发布时间】: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


【解决方案1】:

只是添加了延迟,一切正常。

return 语句前延迟 5 秒

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 1970-01-01
    • 2021-05-23
    • 2023-02-01
    • 2016-03-29
    相关资源
    最近更新 更多