[p4] Changing client Owner

Lewis Baker lewis at isite3d.com.au
Tue May 30 22:26:46 PDT 2006


Mohsin Saleem Khan wrote:
> Hi,
> 
> I am trying to change  client spec owner in perforce, right now I am doing 
> p2 client <name> and than edit it. But I have almost 20 clients to update, 
> is there any other way or can I do it via some kind of script.
> 

Scripting something like this is relatively straight forward with any of
the Perforce API bindings.

For example, using the PyPerforce interface for Python a simple script
such as this would do the trick:

----
#!/usr/bin/python
import sys

if len(sys.argv) < 3:
    print "Usage: %s <owner> [<client>]+" % sys.argv[0]
    sys.exit(1)

try:
    import perforce
except ImportError:
    print "Please install PyPerforce (http://pyperforce.sf.net/)"
    sys.exit(1)

newOwner = sys.argv[1]

p4 = perforce.Connection()
p4.connect()
try:
    for name in sys.argv[2:]:
        print "Changing owner of client %s to %s" % (name, newOwner)
        client = perforce.Client(p4, name)
        client['Owner'] = newOwner
        client.save()
finally:
    p4.disconnect()
----

Hope that helps.

Cheers,
Lewis.

-- 
Lewis Baker                                               I-SiTE
Software Engineer                               3D Laser Imaging
Email  : lewis at isite3d.com.au         http://www.isite3d.com.au/


More information about the perforce-user mailing list