Re: [PyPerforce] how to pass the global options to run command
Status: Beta
Brought to you by:
lewisbaker
From: Lewis B. <le...@re...> - 2007-10-11 00:07:07
|
Hi Yuan, Sorry for the delay, I've been away from my email recently. > I'm new to pyperforce. I would like to query Perforce to see if a > client spec exists or not. I can use the command line "p4 -u myname -p > testserver:1666 -c clientspecName info" to check the Client field in > the return to decide if the clientspec , clientspecName, exists or > not. When I try to use the run command in pyperforce, p4obj.run('-u', > 'myname', '-p', 'testserver:1666', '-c', 'clientspecName', 'info'). I > got error back. Can somebody help me on how to pass the global options > to a run() command in pyperforce. You can setup these parameters using the attributes on the Connection object. eg. ----- #!/bin/python import perforce p4 = perforce.Connection() p4.user = "myname" p4.port = "testserver:1666" p4.client = "clientspecName" p4.connect() info = p4.run("info").records[0] p4.disconnect() if info['clientName'] == "*unknown*": print "client doesn't exist" else: print "client does exist" ----- I hope that helps. Cheers, Lewis. |