Jump to content

P4Python and global options: working with -ztag

p4python global

  • Please log in to reply
2 replies to this topic

#1 Dromedaries123



  • Members
  • Pip
  • 4 posts

Posted 16 July 2018 - 10:54 PM

I'm trying to run the "p4 -ztag describe <changelist#>" command with the P4Python API using the p4.run method.
However, I am getting an Error: unknown command when I run my python script.

From what I've been reading online, the issue stems from how the p4.run method sends the passed in command directly to the server without invoking the p4 CLI client with the global flags, which is why global parameters aren't recognized with the API.

I haven't been able to find a P4Python API function or property that has the effect of the -ztag global option and would really appreciate help on this.

How would I go about fixing this? (I am trying to parse information from changelists by extracting their status, description, path, etc. which are displayed when I successfully run the -ztag describe command from the commandline.)


#2 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1149 posts

Posted 17 July 2018 - 04:04 PM

P4Python automatically gives you command output for many commands in the form of dictionaries (which is what -ztag is for at the command line).  Look through some of the examples in the P4Python documentation:  https://www.perforce...gramming.submit -- note that rather than running the "describe" command, this example calls a method "fetch_change" that does the same thing behind the scenes but returns the output as a "spec" object with easy access to the file list, description, etc.

If you're running individual commands that don't already return conveniently formatted Python objects, see: https://www.perforce...p4.while_tagged

#3 Dromedaries123



  • Members
  • Pip
  • 4 posts

Posted 23 July 2018 - 08:57 PM

Thank you for your reply. Your examples really helped.

Also tagged with one or more of these keywords: p4python, global

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users