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: 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 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> <53856F53.5010303@timgolden.me.uk> In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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: > > %ProgramFiles%\LibreOffice > 4\program\swriter.exe "C:\Users\Timothy\Documents\myfile.odt" > > should instead be: > > "%ProgramFiles%\LibreOffice > 4\program\swriter.exe" "C:\Users\Timothy\Documents\myfile.odt" > > 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