Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72136
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-05-27 16:01 -0700 |
| References | <29c26176-b573-4ac9-bf41-a18a53d7dfb9@googlegroups.com> <mailman.10362.1401175475.18130.python-list@python.org> |
| Message-ID | <e88a0683-8332-4db7-934b-39d5efc6d436@googlegroups.com> (permalink) |
| Subject | Re: Command prompt not shown when running Python script with subprocess on Windows |
| From | ps16thypresenceisfullnessofjoy@gmail.com |
Sorry for not being explicit enough. I am aware that this would work if I called python.exe path-to-script.py with shell=False.
In my Python program, I parse an XML file like the one I have included below. Then I loop through the paths of the apps listed in it and run them by calling something like this:
for app_path in app_paths:
args = shlex.split(app_path.replace("\\", "\\\\"))
args = [arg.replace("\\\\", "\\") for arg in args]
args[0] = os.path.expandvars(args[0])
subprocess.Popen(args, shell='__WXMSW__' in wx.PlatformInfo)
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 it is possible to make a Windows shortcut for path-to-script.py without the python.exe in front of it and have it open in its own command prompt, I want to be able to do the same thing in my XML file, but this is what I cannot figure out.
By the way, is there a simpler way to use shlex.split and return valid Windows paths than the way I am doing (as shown above)?
Thank you.
-- Timothy
*** Contents of app_list.xml below ***
<?xml version='1.0' encoding='utf-8'?>
<apps>
<app name="Mozilla Firefox">%ProgramFiles%\Mozilla Firefox\firefox.exe</app>
<app name="Mozilla Thunderbird">%ProgramFiles%\Mozilla Thunderbird\thunderbird.exe</app>
<app name="LibreOffice Writer">%ProgramFiles%\LibreOffice 4\program\swriter.exe "C:\Users\Timothy\Documents\myfile.odt"</app>
<app name="**Python script**">C:\Users\Timothy\Documents\Python\myscript.py</app>
</apps>
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