简体   繁体   中英

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

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:

做:

p4 -Ztag -F %clientName% info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM