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 

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\')
>>> shlex.split(r'C:\\Users\\Timothy\\Documents\\Python\\')
>>> shlex.split(r'C:\Users\Timothy\Documents\Python\', posix=False)

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.

I think I'll use PyWin32 as you suggested if it's available on the user's 
system. If it's not, the user will just be required to prefix 
with python.exe. (When I first asked my question, I was thinking I might just 
need to pass a certain STARTUPINFO flag to subprocess.Popen, but it looks like 
that's not the solution.)

-- Timothy

Reply via email to