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


Groups > comp.lang.python > #72377

Re: Command prompt not shown when running Python script with subprocess on Windows

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Windows': 0.02; 'subject:not': 0.03; 'argument': 0.05; 'subject:Python': 0.06; 'paths': 0.07; 'variables': 0.07; 'arguments,': 0.09; 'emulate': 0.09; 'idea?': 0.09; 'parsing': 0.09; 'stating': 0.09; 'subject:script': 0.09; 'windows': 0.15; 'constitutes': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:192.168.0.29': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'shortcut': 0.16; 'subject: \n ': 0.16; 'subject:when': 0.16; 'tjg': 0.16; 'tweak': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'skip:p 40': 0.19; 'entered': 0.20; 'header:User-Agent:1': 0.23; 'decide': 0.24; 'looks': 0.24; 'environment': 0.24; 'header:In- Reply-To:1': 0.27; 'xml': 0.29; "doesn't": 0.30; 'said,': 0.30; "i'm": 0.30; '(which': 0.31; 'program,': 0.31; 'too.': 0.31; 'quotes': 0.31; 'file': 0.32; 'class': 0.32; 'guess': 0.33; "i'd": 0.34; 'subject:with': 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'combination': 0.36; 'useful': 0.36; "i'll": 0.36; 'too': 0.37; 'implement': 0.38; 'sometimes': 0.38; 'winning': 0.38; 'to:addr:python-list': 0.38; 'embedded': 0.39; 'though,': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'users': 0.40; 'simply': 0.61; "you're": 0.61; 'first': 0.61; 'cut': 0.74; 'obvious': 0.74; 'prize': 0.74; 'behavior': 0.77; 'from:addr:mail': 0.83; 'env': 0.84; 'tie': 0.84; 'vars': 0.91
Date Sun, 01 Jun 2014 17:31:04 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Command prompt not shown when running Python script with subprocess on Windows
References <29c26176-b573-4ac9-bf41-a18a53d7dfb9@googlegroups.com> <mailman.10362.1401175475.18130.python-list@python.org> <e88a0683-8332-4db7-934b-39d5efc6d436@googlegroups.com> <53856F53.5010303@timgolden.me.uk> <mailman.10417.1401306385.18130.python-list@python.org> <cc381969-d75b-42ce-81fe-5577501b1e06@googlegroups.com> <mailman.10449.1401363665.18130.python-list@python.org> <fe0d5d14-e7eb-4b60-90a4-12ff1dd74e17@googlegroups.com>
In-Reply-To <fe0d5d14-e7eb-4b60-90a4-12ff1dd74e17@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.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10524.1401640265.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401640265 news.xs4all.nl 2918 [2001:888:2000:d::a6]:57760
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72377

Show key headers only | View raw


29/05/2014 20:21, ps16thypresenceisfullnessofjoy@gmail.com wrote:
> That's interesting, now I learned something else too. As I said
> before, though, I want users to be able to enter paths in the XML
> file exactly the way they would be entered in a Windows shortcut.

[...]

> Since in a Windows shortcut you don't need to put quotes around a
> path that doesn't contain spaces, I want to follow that behavior in
> my program as well.

[...]

> So I guess I'll still have to do my "shlex dance" (which for some
> reason I keep on mistyping as "shlex dane" :-)) unless I can learn a
> better way to do it.

It looks like it. Sometimes the behaviour out of the box just doesn't 
cut it. Don't forget, also, that you can subclass, eg, the shlex.shlex 
class and tweak it to do what you need.

>
> Also, is my calling os.path.expandvars only on the first argument a
> good idea? I want to accept environment variables in my program, but
> I don't want to call os.path.expandvars on all the arguments, because
> I want to let other programs take care of parsing their own
> arguments.

I'd say that's a call only you can make given what you know of your 
requirements. That said, I'm not sure what the "other programs" are 
going to do with any embedded env vars except to expand them as you're 
doing.

Ultimately, don't tie yourselves in knots either trying too hard to 
emulate Windows shortcuts or trying too hard to use shlex.split out of 
the box. Decide what constitutes a useful combination of features and 
implement them as simply as you can. [He says, winning the prize for 
stating the obvious :) ]

TJG

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


Thread

Command prompt not shown when running Python script with subprocess on Windows ps16thypresenceisfullnessofjoy@gmail.com - 2014-05-26 17:03 -0700
  Re:Command prompt not shown when running Python script with subprocess on Windows Dave Angel <davea@davea.name> - 2014-05-27 03:20 -0400
  Re: Command prompt not shown when running Python script with subprocess on Windows Stephen Hansen <me+python@ixokai.io> - 2014-05-26 23:38 -0700
    Re: Command prompt not shown when running Python script with subprocess on Windows ps16thypresenceisfullnessofjoy@gmail.com - 2014-05-27 16:01 -0700
      Re: Command prompt not shown when running Python script with subprocess on Windows Tim Golden <mail@timgolden.me.uk> - 2014-05-28 06:08 +0100
        Re: Command prompt not shown when running Python script with subprocess on Windows ps16thypresenceisfullnessofjoy@gmail.com - 2014-05-28 13:22 -0700
      Re: Command prompt not shown when running Python script with subprocess on Windows Tim Golden <mail@timgolden.me.uk> - 2014-05-28 20:46 +0100
        Re: Command prompt not shown when running Python script with subprocess on Windows ps16thypresenceisfullnessofjoy@gmail.com - 2014-05-28 13:46 -0700
          Re: Command prompt not shown when running Python script with subprocess on Windows Tim Golden <mail@timgolden.me.uk> - 2014-05-29 12:41 +0100
            Re: Command prompt not shown when running Python script with subprocess on Windows ps16thypresenceisfullnessofjoy@gmail.com - 2014-05-29 12:21 -0700
              Re: Command prompt not shown when running Python script with subprocess on Windows Tim Golden <mail@timgolden.me.uk> - 2014-06-01 17:31 +0100
                Re: Command prompt not shown when running Python script with subprocess on Windows ps16thypresenceisfullnessofjoy@gmail.com - 2014-06-04 13:25 -0700

csiph-web