Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72235
| Date | 2014-05-29 12:41 +0100 |
|---|---|
| From | Tim Golden <mail@timgolden.me.uk> |
| Subject | Re: Command prompt not shown when running Python script with subprocess on Windows |
| References | (1 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10449.1401363665.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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