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


Groups > comp.lang.python > #72248

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

Newsgroups comp.lang.python
Date 2014-05-29 12:21 -0700
References (2 earlier) <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> <mailman.10449.1401363665.18130.python-list@python.org>
Message-ID <fe0d5d14-e7eb-4b60-90a4-12ff1dd74e17@googlegroups.com> (permalink)
Subject Re: Command prompt not shown when running Python script with subprocess on Windows
From ps16thypresenceisfullnessofjoy@gmail.com

Show all headers | View raw


That's interesting, now I learned something else too. As I said before, though, I want users to be able to enter paths in the XML file exactly the way they would be entered in a Windows shortcut.
(Actually, my program currently only has one Windows user, for whom I develop it [I don't even use it myself :-0].)

Since in a Windows shortcut you don't need to put quotes around a path that doesn't contain spaces, I want to follow that behavior in my program as well.

So actually, I see that the line:

<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>

because there are no spaces in the second path, but there is a space in the first one.

So I guess I'll still have to do my "shlex dance" (which for some reason I keep on mistyping as "shlex dane" :-)) unless I can learn a better way to do it.

Also, is my calling os.path.expandvars only on the first argument a good idea? I want to accept environment variables in my program, but I don't want to call os.path.expandvars on all the arguments, because I want to let other programs take care of parsing their own arguments.

I'm just wondering if I should relook at the whole way that I am doing things here. Maybe it would be better to just use shlex.split and subprocess.Popen and not try to follow the behavior of Windows shortcuts so closely? (But then it might be hard for some Windows users to understand how to use the program if I didn't.) What do you think?

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