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

Tony Whitley (Hotmail) tony_whitley at hotmail.com
Tue Sep 16 07:26:02 PDT 2008


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/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


 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20080916/08c9fdd6/attachment-0001.html>


More information about the p4python mailing list