Can't write to a directory made w/ os.makedirs

Tim Golden mail at timgolden.me.uk
Mon Jan 2 06:11:27 EST 2012


On 02/01/2012 03:14, David Goldsmith wrote:
> Here's my script, in case that helps:

It certainly does. A few things occur to me.

First, you
shouldn't need to double-quote the path; the subprocess.call
should do that for you as long as you're using the list
version of the param -- which you are.

Second, you almost certainly don't want to be using the
env param, at least not in the way you are. Depending on
the way in which your app runs, either pass the appropriate
directory as the cwd= param, or copy and override the
current environ dict, ie either do this:

subprocess.call (
   ['c:/program files/somewhere/app.exe', 'blah1', 'blah2'],
   cwd="c:/somewhere/else"
)

or this:

env = dict (os.environ)
env['PATH'] = "c:/somewhere/else"
# or env['PATH'] += ";c:/somewhere/else"
subprocess.call (
   ['c:/program files/somewhere/app.exe', 'blah1', 'blah2'],
   env=env
)


See if any of that helps

TJG



More information about the Python-list mailing list