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


Groups > comp.lang.python > #72235

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.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; 'interpreter': 0.05; 'subject:Python': 0.06; 'test,': 0.07; 'converted': 0.09; 'escape': 0.09; 'skip:% 20': 0.09; 'subject:script': 0.09; 'worked.': 0.09; "wouldn't": 0.14; 'windows': 0.15; 'backslashes': 0.16; 'be:': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'learnt': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'preserved': 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; 'skip:[ 30': 0.16; 'skip:[ 40': 0.16; 'skip:[ 50': 0.16; 'subject: \n ': 0.16; 'subject:when': 0.16; 'suppose.': 0.16; 'there!': 0.16; 'tjg': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'skip:p 40': 0.19; 'examples': 0.20; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'issue.': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'parse': 0.24; 'received:192.168.100': 0.24; 'removed.': 0.24; 'file.': 0.24; 'skip:" 30': 0.26; 'suggested': 0.26; 'this:': 0.26; 'second': 0.26; 'post': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'xml': 0.29; '>>>>': 0.31; 'though.': 0.31; 'file': 0.32; 'raw': 0.33; 'third': 0.33; 'subject:with': 0.35; 'something': 0.35; 'test': 0.35; 'acceptable': 0.36; 'skip:s 60': 0.36; 'words,': 0.36; 'doing': 0.36; "didn't": 0.36; 'shows': 0.36; 'should': 0.36; 'thank': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 'show': 0.63; 'said:': 0.68; 'behaviors': 0.74; 'from:addr:mail': 0.83; 'replies.': 0.84; 'mistake': 0.91; 'skip:4 20': 0.91
Date Thu, 29 May 2014 12:41:02 +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.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>
In-Reply-To <cc381969-d75b-42ce-81fe-5577501b1e06@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
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.10449.1401363665.18130.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401363665 news.xs4all.nl 2914 [2001:888:2000:d::a6]:40064
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72235

Show key headers only | View raw


On 28/05/2014 21:46, ps16thypresenceisfullnessofjoy@gmail.com wrote:
> 
> Thank you for your replies. I tried what you suggested in your second
> post and it worked.
> 
> That was actually a mistake in the app_list.xml file. As you said:
> 
> <app name="LibreOffice Writer">%ProgramFiles%\LibreOffice
> 4\program\swriter.exe "C:\Users\Timothy\Documents\myfile.odt"</app>
> 
> should instead be:
> 
> <app name="LibreOffice Writer">"%ProgramFiles%\LibreOffice
> 4\program\swriter.exe" "C:\Users\Timothy\Documents\myfile.odt"</app>
> 
> I just made that file as a sample, and didn't actually test it.
> 
> My "shlex dance" has nothing to do with that, though. A few examples
> from the interactive interpreter should explain why I am doing it (I
> used raw strings in these examples so that I wouldn't need to escape
> the backslashes):
> 
>>>> import shlex 
>>>> shlex.split(r'C:\Users\Timothy\Documents\Python\myscript.py')
> ['C:UsersTimothyDocumentsPythonmyscript.py']
>>>> shlex.split(r'C:\\Users\\Timothy\\Documents\\Python\\myscript.py')
>
>>>> 
['C:\\Users\\Timothy\\Documents\\Python\\myscript.py']
>>>> shlex.split(r'C:\Users\Timothy\Documents\Python\myscript.py',
>>>> posix=False)
> ['C:\\Users\\Timothy\\Documents\\Python\\myscript.py']
> 
> The first example shows that single backslashes get removed. The
> second example shows that double backslashes are preserved intact.
> The third example shows that if posix=False, single backslashes are
> converted to double backslashes. None of these three behaviors are
> acceptable to correctly parse a Windows path, which is why I am doing
> what I am to work around the issue.

Well I certainly learnt something there! An additional test, which you
don't show is this:

>>> import shlex
>>> shlex.split(r'"c:\users\timothy\documents"')
['c:\\users\\timothy\\documents']
>>>

In other words, given the double-quoted data in your XML file, I think
it will do the right thing by Windows backslashes. YMMV, I suppose.

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