Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18320

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

Date 2012-01-02 11:11 +0000
From Tim Golden <mail@timgolden.me.uk>
Subject Re: Can't write to a directory made w/ os.makedirs
References <50693cc2-93c9-481d-9fb1-42312e69b2d9@c42g2000prb.googlegroups.com> <mailman.4289.1325410678.27778.python-list@python.org> <91830ffb-00d9-4fd1-b771-ad59374334ec@n22g2000prh.googlegroups.com> <mailman.4292.1325430363.27778.python-list@python.org> <6348b96c-f7a9-4ca6-a704-c90d25f07788@y25g2000prg.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.4306.1325502694.27778.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[Windows 7, Python 2.6] Can't write to a directory made w/ os.makedirs OlyDLG <d.l.goldsmith@gmail.com> - 2011-12-31 14:13 -0800
  Re: [Windows 7, Python 2.6] Can't write to a directory made w/ os.makedirs Tim Golden <mail@timgolden.me.uk> - 2012-01-01 09:37 +0000
    Re: Can't write to a directory made w/ os.makedirs David Goldsmith <eulergaussriemann@gmail.com> - 2012-01-01 04:05 -0800
      Re: Can't write to a directory made w/ os.makedirs Tim Golden <mail@timgolden.me.uk> - 2012-01-01 15:05 +0000
        Re: Can't write to a directory made w/ os.makedirs David Goldsmith <eulergaussriemann@gmail.com> - 2012-01-01 19:14 -0800
          Re: Can't write to a directory made w/ os.makedirs MRAB <python@mrabarnett.plus.com> - 2012-01-02 03:43 +0000
            Re: Can't write to a directory made w/ os.makedirs David Goldsmith <eulergaussriemann@gmail.com> - 2012-01-03 07:17 -0800
          Re: Can't write to a directory made w/ os.makedirs Tim Golden <mail@timgolden.me.uk> - 2012-01-02 11:11 +0000
          Re: Can't write to a directory made w/ os.makedirs Dave Angel <d@davea.name> - 2012-01-02 09:09 -0500
            Re: Can't write to a directory made w/ os.makedirs David Goldsmith <eulergaussriemann@gmail.com> - 2012-01-02 18:34 -0800

csiph-web