[p4] FW: Invoking Perforce from Python

Isaac Rodriguez isaac.rodriguez at autodesk.com
Wed May 9 05:38:46 PDT 2007


Why are you using os.popen to run Perforce commands when there is a
great "Perforce Python" module downloadable from the Perforce website?

http://public.perforce.com/guest/robert_cowham/perforce/API/python/index
.html


Thanks,
 
Isaac
 
 
 

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Looney, James B
Sent: Tuesday, May 08, 2007 7:07 PM
To: perforce-user at perforce.com
Subject: [p4] Invoking Perforce from Python

Ok, I'm undecided as to whether this is a Python or a Perforce issue,
either way, I figured out the solution.  Here's what's happening:

I invoke a Python script that runs Perforce commands (using os.popen)
I use os.chdir( <some other directory> )
Then attempt to invoke Perforce again (using os.popen)
Perforce believes that I'm in the original directory from which the
Python script was invoked, NOT the directory I changed to from within
Python.

The solution?  Use os.putenv( "PWD", os.path.realpath( os.curdir ) ),
then use os.popen.

Now, my questions:
1) Is it reasonable to expect Perforce to figure out where it is from
using PWD?  Is there another way? (My coworker made some reference to
being able to figure out where a program's invoked from without using
PWD).

2) Would this be considered a disconnect in Python?

-JB
_______________________________________________
perforce-user mailing list  -  perforce-user at perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user



More information about the perforce-user mailing list