[p4python] P4.run("clients -u username") doesn't work?

Sven Erik Knop sknop at perforce.com
Tue Sep 16 07:40:24 PDT 2008


Hi Tony,

You need to pass the arguments as separate strings, as in

  clientList = p4c.run("clients", "-u", "twhitley")

or even

  clientList = p4c.run_clients("-u", "twhitley")

Try whether this solves your problem please.

Thank you for pointing out the bug in the documentation. I will make 
sure it gets fixed.

Cheers

Sven Erik

Tony Whitley (Hotmail) wrote:
> Running this test script
>
>     import P4
>      
>     p4c = P4.P4()
>      
>     p4c.connect()
>      
>     info = p4c.run("info") # Run "p4 info" (returns a dict)
>     version = info[0]['serverVersion'] # Get server version
>     print version
>     clientList = p4c.run("clients", "-m 10")
>     for client in clientList:
>       print client['Update']
>     print
>     clientList = p4c.run("clients -u twhitley")
>     print clientList
>
> produces this output
>
>     P4D/LINUX26X86_64/2008.1/164042 (2008/09/07)
>     1221216538
>     1216737109
>     1185476948
>     1219181571
>     1172060263
>     1207694566
>     1217964326
>     1218644399
>     1219434399
>     1214600362
>      
>     Traceback (most recent call last):
>       File "p4clientsTEST.py", line 15, in <module>
>         clientList = p4c.run("clients -u twhitley")
>       File "c:\utils\python\lib\site-packages\P4.py", line 288, in run
>         return P4API.P4Adapter.run(self, *self.__flatten(args))
>     P4.P4Exception: [P4#run] Errors during command execution( "p4
>     clients -u twhitley" )
>      
>             [Error]: Unknown command.  Try 'p4 help' for info.
>
> p4 clients -u twhitley works OK from the command line. 
> p4c.run_clients("-u twhitley") doesn't work either
>  
> I need this as my previous method of executing 'p4 clients' and then 
> filtering the list takes an /awful/ lot longer than with Robert's 
> original version of p4python on our list of  138189 clients, much 
> slower than 'p4 clients > nul'
>  
> There also seems to be an error in 
> http://www.perforce.com/perforce/doc.073/manuals/p4script/p4scriptpdf 
> <http://www.perforce.com/perforce/doc.073/manuals/p4script/p4script.pdf> which 
> says
>
>     info = p4.run("info") # Run "p4 info" (returns a dict)
>     s = info['serverVersion'] # Get server version
>
> I had to change that to
>  
>
>     s = info*[0]*['serverVersion'] # Get server version
>      
>
> >python --version
> Python 2.5.1
>  
> Running on Windows XP. P4python downloaded yesterday.
>  
>
> --
> /*Tony Whitley*/
>
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> p4python mailing list
> p4python at perforce.com
> http://maillist.perforce.com/mailman/listinfo/p4python
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20080916/b9bd3ace/attachment-0001.html>


More information about the p4python mailing list