1

I am working on a Python script, in that I am printing all stream information of perforce using:

p4 -ztag stream -o //streams/xyz

output looks like:

                Stream //streams/xyz 
                Update 2015/03/12 16:05:33
                Acessed 2014/03/14 09:55:38 
                Owner abc 
                Parent  //streams/klm
                Remapped0 fgh/hjk....
                Remapped1 uhk/dtj...
                Remapped2 hjjk/.. etc 

this way output is coming.
I am calling from python as :

 subprocess.Popen(['p4','-ztag','stream','-o',//streams/xyz], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].                                          Now, i want to display only Path fields not the rest i.e owner, update, access, etc. So, how will i get this?

Now I want to have the information regarding only one field named as "Remapped" not the rest like owner, Parent etc.

So, How do I use the filter command to get only the specific field?

kashyap
  • 31
  • 3
  • Can you please include an example of what the output looks like? Also, how are you calling that command from Python? What have you done yourself already and where are you currently stuck? – Martijn Pieters Apr 10 '15 at 06:33
  • You should [edit] your question to add additional information like that. – Martijn Pieters Apr 10 '15 at 06:42

1 Answers1

1

I'd recommend using the P4Python API, which will make it very simple:

http://www.perforce.com/perforce/doc.current/manuals/p4script/python.p4.html#python.p4.fetch_spectype

http://www.perforce.com/perforce/doc.current/manuals/p4script/python.p4_spec.html

p4.fetch_stream( "//streams/xyz" )._Remapped

will get you the value of the Remapped field, etc.

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • hi i used: p4.fetch_stream( "//streams/xyz" )._Remapped but it is showing me 'p4.fetch_stream' is not recognized internal or external command. what should i do now? – kashyap Apr 10 '15 at 08:32
  • You need to install the P4Python API before you can use it in your script: http://www.perforce.com/perforce/doc.current/manuals/p4script/python.installation.html See also the "Programming with P4Python" section to see how you set up a connection etc: http://www.perforce.com/perforce/doc.current/manuals/p4script/python.programming.html – Samwise Apr 10 '15 at 15:36
  • Is it not possible to achieve it without using P4Python API?. I have used p4 -ztag stream -o //streams/xyz and its perfectly working fine without P4Python API. – kashyap Apr 11 '15 at 10:26
  • There are always multiple ways to accomplish something (you always have the option of writing something from scratch rather than using what's already written), but in this case I think using the API is the easiest way. :) – Samwise Apr 11 '15 at 16:04