How to get “Client name:” of a perforce workspace using “p4 info” from python script?

耗尽温柔 提交于 2019-12-24 07:48:45

问题


I have a scenario where i need to have perforce workspace Client name information. Trying out with script as follows:

    import sys
    import subprocess
    cmd = "p4 info | grep" + """ "Client name" """ +""
    print ("p4 command is: ",cmd)
    p4 = subprocess.call(cmd)
    print( p4)       

Where i get out put as :

    p4 command is: p4 info | grep "Client name"
    Usage: info [-s]
    Unexpected arguments.
    1

I tried doing as follows too but did not worked:

    import sys
    import subprocess
    p4_info = subprocess.call([sys.executable, "p4 info | grep "Client name""])

I actually want to fetch only Client name information. So, suggest me how i may have that. If there is another way of doing it please suggest. The script will be executed within the workspace and shall return the only Client name:


回答1:


Do:

p4 -Ztag -F %clientName% info


来源:https://stackoverflow.com/questions/47579641/how-to-get-client-name-of-a-perforce-workspace-using-p4-info-from-python-sc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!