[Tutor] subprocess.Popen(..., cwd) and UNC paths

Albert-Jan Roskam fomcl at yahoo.com
Fri May 1 15:03:41 CEST 2015


----------------------------
On Thu, Apr 30, 2015 1:12 AM CEST eryksun wrote:

>On Wed, Apr 29, 2015 at 11:54 AM, Albert-Jan Roskam
><fomcl at yahoo.com.dmarc.invalid> wrote:
>> Hmmm, that sounds pretty convincing indeed (makes it even stranger that CD works the way it works).
>> I believe it threw a WindowsError, indicating that the file(s) could not be found, because the dir was
>> not changed. I actually first ran into this problem with this script, so with my current script I
>> immediately refrained from using cwd:
>> http://code.activestate.com/recipes/578883-git-pre-commit-hook-to-reject-large-files-using-py/
>> Git gave a fatal error in windows and the pushd/popd fixed it.
>
>I don't see why you'd need shell=True. Windows supports UNC paths in
>the working directory, but the cmd.exe shell (being a crusty relic of
>the 1980s) 

"Crusty relic" LOL :-)

<does not. So just use the default value, shell=False.
>(However, on POSIX systems, unlike Windows, using shell=False requires
>`cmd` to be a list.) 

Ah, maybe that caused the confusion. I used a str for cmd because I found it more readable that way. I could do cmd.split().

BTW, there's no need to explicitly pass
>cwd=os.getcwd(). The default behavior is to inherit the working
>directory of the current process.

Ok, I'll try this. I remember I was messing with this (hence the 'verbose' parameter). So os.getcwd() == os.path.dirname(os.path.abspath(__file__)) here? (Sorry, I can't try this now, even though I have QPython on my phone)

Best wishes,
Albert-Jan


More information about the Tutor mailing list