Jump to content


Can I stop P4Python from printing logging information to stdout?

python p4python

  • Please log in to reply
3 replies to this topic

#1 philipjag

philipjag

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 25 January 2014 - 07:03 AM


Most methods in the P4Python API print logging information to standard out. I'm writing a script where I use stdout for communicating the script's status and I don't want my users to be confused by the logging information from P4Python.

Example:

import P4
client
= P4.P4()
client
.connect()
will print

P4 [username@workspace perforce:1666] connected

#2 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 27 January 2014 - 06:33 AM

Is that your entire script? I just ran the same thing and found I only saw that output if I wrapped the client.connect() call with a print statement. I'm just wondering if you have something configured in your python script to always print to stdout. Have you tried:

import P4
client = P4.P4()
some_variable = client.connect()

Are you using Python 2 or Python 3?

#3 rhummer

rhummer

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts
  • LocationMadison, WI

Posted 27 January 2014 - 06:44 PM

I use the python api quite extensively and it doesn't print anything unless I use an explicit print or use an OutputHandler object.
Lead Tools Engineer
Raven Software

#4 philipjag

philipjag

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 28 January 2014 - 04:49 AM

You're right. Thank you.





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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users