[p4] Invoking Perforce from Python
Dave Lewis
dlewis78731 at gmail.com
Tue May 8 18:15:39 PDT 2007
I have encountered this from time to time when using perl. If I'm
executing a command line, the easiest fix is to specify the directory
with -d
dave
On 5/8/07, Looney, James B <james.b.looney at lmco.com> wrote:
> 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