[Tutor] subprocess.Popen(..., cwd) and UNC paths
eryksun
eryksun at gmail.com
Thu Apr 30 01:12:34 CEST 2015
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) 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.) BTW, there's no need to explicitly pass
cwd=os.getcwd(). The default behavior is to inherit the working
directory of the current process.
More information about the Tutor
mailing list