Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18310
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!feed.xsnews.nl!border-3.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'sys': 0.05; 'example)': 0.07; 'script,': 0.07; 'python': 0.08; 'context.': 0.09; 'directories?': 0.09; 'failing': 0.09; 'from:addr:python': 0.09; 'none)': 0.09; 'subprocess': 0.09; 'am,': 0.12; 'exception': 0.12; 'def': 0.13; "'')": 0.16; 'crack': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'invoking': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mkdir': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'res': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'default,': 0.23; 'command': 0.24; 'creating': 0.25; "i'm": 0.26; 'skip:[ 10': 0.27; 'import': 0.27; "skip:' 10": 0.29; 'cmd': 0.30; 'parent': 0.30; 'stat': 0.30; 'sub': 0.30; 'tjg': 0.30; 'yes.': 0.30; '(the': 0.30; 'skip:( 30': 0.31; 'skip:( 20': 0.31; "isn't": 0.33; 'header:User-Agent:1': 0.33; 'there': 0.33; 'to:addr:python-list': 0.34; 'received:84': 0.34; 'certain': 0.34; 'calling': 0.34; 'reply-to:addr:python.org': 0.34; 'root': 0.34; 'running': 0.35; 'something': 0.35; 'unless': 0.35; 'david': 0.36; 'but': 0.37; 'think': 0.37; 'doing': 0.38; 'processing': 0.39; 'should': 0.39; 'files': 0.39; 'called': 0.40; 'to:addr:python.org': 0.40; 'you.': 0.63; 'here': 0.65; 'nothing.': 0.67; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'golden': 0.73; 'deliberate': 0.84; 'directories,': 0.84; 'fl:': 0.84; 'subject:write': 0.84; 'elevated': 0.91; 'subject:made': 0.93; 'absolutely': 0.98 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=J8QoHXbS c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=9jsOeB20M3cA:10 a=GzNmwhyEvBsA:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=248R0ej3AAAA:8 a=9yC3q-q1Fu8hAyx7RIMA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Mon, 02 Jan 2012 03:43:43 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| 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> |
| In-Reply-To | <6348b96c-f7a9-4ca6-a704-c90d25f07788@y25g2000prg.googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4301.1325476003.27778.python-list@python.org> (permalink) |
| Lines | 82 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1325476003 news.xs4all.nl 6947 [2001:888:2000:d::a6]:57965 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18310 |
Show key headers only | View raw
On 02/01/2012 03:14, David Goldsmith wrote:
> On Jan 1, 7:05 am, Tim Golden<m...@timgolden.me.uk> wrote:
>> On 01/01/2012 12:05, David Goldsmith wrote:
>> >> 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?
>>
>> In the general case, no. By default, a subprocess will have
>> the same security context as its parent. The exception is
>> where the parent (the Python processing invoking subprocess.call
>> in this example) is already impersonating a different user;
>> in that case, the subprocess will inherit its grandparent's
>> context.
>>
>> But unless you're doing something very deliberate here then
>> I doubt if that's biting you.
>>
>> Can I ask: are you absolutely certain that the processes
>> you're calling are doing what you think they are and failing
>> where you think they're failing?
>>
>> TJG
>
> I'm a mathematician: the only thing I'm absolutely certain of is
> nothing.
>
> Here's my script, in case that helps:
>
> import os
> import sys
> import stat
> import os.path as op
> import subprocess as sub
> from os import remove
> from os import listdir as ls
> from os import makedirs as mkdir
>
> def doFlac2Mp3(arg, d, fl):
> if '.flac' in [f[-5:] for f in fl]:
> newD = d.replace('FLACS', 'MP3s')
> mkdir(newD)
> for f in fl:
> if f[-5:]=='.flac':
> root = f.replace('.flac', '')
> cmd = ['"C:\\Program Files (x86)\\aTunes\\win_tools\
> \flac.exe" -d ' +
> '--output-prefix=' + newD + '\\', f]
> res = sub.call(cmd)#, env={'PATH': os.defpath})
> if not res:
> cmd = ['"C:\\Program Files (x86)\\aTunes\\win_tools
> \\lame.exe" -h',
> newD + root + '.wav', newD + root +
> '.mp3']
> res = sub.call(cmd)#, env={'PATH': os.defpath})
> if not res:
> rf = newD + root + '.wav'
> remove(rf)
>
> top=sys.argv[1]
> op.walk(top, doFlac2Mp3, None)
I think that if the command line should be something like:
"C:\Program Files (x86)\aTunes\win_tools\flac.exe" -d
--output-prefix=FOO\ BAR
then the cmd should be something like:
cmd = ['C:\\Program Files (x86)\\aTunes\\win_tools\\flac.exe', '-d',
'--output-prefix="' + newD + '\\"', f]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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