On Jan 1, 1:37 am, Tim Golden <m...@timgolden.me.uk> wrote:
> On 31/12/2011 22:13, OlyDLG wrote:
>  > Hi!  I'm working on a script utilizing os.makedirs to make directories
>  > to which I'm then trying to write files created by exe's spawned w/
>  > subprocess.call; I'm developing in Stani's Python Editor, debugging
>  > using Winpdb.  I've gotten to the point where
>  > subprocess.Popen._execute_child is raising a WindowsError(5,'Access is
>  > denied') exception.  I've tried: setting the mode in the makedirs
>  > call; using os.chmod(<dir>, stat.S_IWRITE); and even setting a
>  > breakpoint before the subprocess.call and unsetting the read-only
>  > attribute of the pertinent directory tree using the Windows directory
>  > Properties dialog--which doesn't "take," if that's a clue--all to no
>  > avail.
>
> Whatever you're trying to do, resetting the read-only bit
> on the Windows directory is not the answer. It has, bizarrely,
> nothing to do with the read/write-ness of a directory; rather,
> it reflects the system-ness of a folder.
>
> There's no general answer I can see to give, without
> knowing what the security is on your folders or what
> other thing might impede your processes from writing
> files in them. Is it definite that the ERROR_ACCESS_DENIED
> is in fact the result of attempting to write a file into
> one of the newly-created directories?
>
> Can you do something like this (adapt for your own environment):
>
> <code>
> import os, sys
> import subprocess
>
> os.makedirs ("c:/temp/a/b/c")
>
> with open ("c:/temp/a/b/c/test1.txt", "w"):
>    pass
>
> subprocess.call ([
>    sys.executable,
>    "-c",
>    "open ('c:/temp/a/b/c/test2.txt', 'w').close ()"
> ])
>
> </code>
>
> ie can the Python process creating the directories,

Yes.

> and a subprocess called from it create a simple file?

No.

> Depending on where you are in the filesystem, it may indeed
> be necessary to be running as administrator. But don't try
> to crack every security nut with an elevated sledgehammer.

If you mean running as admin., those were my sentiments exactly.  So,
there isn't something specific I should be doing to assure that my
subproceses can write to directories?
>
> TJG

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to