Issue
What method do you use a lot when controlling p4 command with Python?
- Use p4 module
- Control p4 command using subprocess ("p4 change")
I'm currently creating tool the second method
Solution
I find the simplest way to translate from command line to P4Python is the p4.run()
command. You just pass in the command you want to run as the first argument and then add each P4 argument after that.
For example, in the terminal:
p4 changes
In Python would be:
p4.run("changes")
Terminal:
p4 describe 153
Python:
p4.run("describe", 153)
So a super simple example of just printing the results of p4 changes would be something like this:
from P4 import P4
p4 = P4()
p4.connect()
changelists = p4.run("changes")
print(changelists)
p4.disconnect()
There are other ways to run certain commands and some extra steps for things like submitting changelists so be sure to check the documentation: https://www.perforce.com/manuals/p4python/Content/P4Python/python.p4.html#Instance_Methods_..39
Hopefully this helps you get started!
Answered By - Jase Lindgren
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.