From: Chris Rebert on
On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft <_rdi_(a)web.de> wrote:
> klausfpga schrieb:
>> Hi,
>>
>> I have a Python script which wants to start a subprocess and wait for
>> it to finish.
>>
>> However I would like to have NO command window popping up during
>> execution.
>
> You need to specify the hide parameter for windows.
>
> import subprocess
> kwargs = {}
> if subprocess.mswindows:
>    su = subprocess.STARTUPINFO()
>    su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
>    su.wShowWindow = subprocess.SW_HIDE
>    kwargs['startupinfo'] = su
> process = subprocess.Popen( (r'c:\python25\python.exe',
>    r'd:\projekte\bar.py'), **kwargs )

Interestingly, none of that appears to be documented. I smell a docs
bug waiting to be reported.

Cheers,
Chris
--
http://blog.rebertia.com
From: Martin P. Hellwig on
Chris Rebert wrote:
> On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft <_rdi_(a)web.de> wrote:
>> klausfpga schrieb:
>>> Hi,
>>>
>>> I have a Python script which wants to start a subprocess and wait for
>>> it to finish.
>>>
>>> However I would like to have NO command window popping up during
>>> execution.
>> You need to specify the hide parameter for windows.
>>
>> import subprocess
>> kwargs = {}
>> if subprocess.mswindows:
>> su = subprocess.STARTUPINFO()
>> su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
>> su.wShowWindow = subprocess.SW_HIDE
>> kwargs['startupinfo'] = su
>> process = subprocess.Popen( (r'c:\python25\python.exe',
>> r'd:\projekte\bar.py'), **kwargs )
>
> Interestingly, none of that appears to be documented.

Except for here:
http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx

> I smell a docs bug waiting to be reported.
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com

--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
From: Chris Rebert on
On Thu, Oct 29, 2009 at 4:37 AM, Martin P. Hellwig
<martin.hellwig(a)dcuktec.org> wrote:
> Chris Rebert wrote:
>>
>> On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft <_rdi_(a)web.de> wrote:
>>>
>>> klausfpga schrieb:
>>>>
>>>> Hi,
>>>>
>>>> I have a Python script which wants to start a subprocess and wait for
>>>> it to finish.
>>>>
>>>> However I would like to have NO command window popping up during
>>>> execution.
>>>
>>> You need to specify the hide parameter for windows.
>>>
>>> import subprocess
>>> kwargs = {}
>>> if subprocess.mswindows:
>>>   su = subprocess.STARTUPINFO()
>>>   su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
>>>   su.wShowWindow = subprocess.SW_HIDE
>>>   kwargs['startupinfo'] = su
>>> process = subprocess.Popen( (r'c:\python25\python.exe',
>>>   r'd:\projekte\bar.py'), **kwargs )
>>
>> Interestingly, none of that appears to be documented.
>
> Except for here:
> http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx

I was referring to the following bits of the subprocess module used in
the above code:
subprocess.mswindows
subprocess.STARTUPINFO()
subprocess.STARTF_USESHOWWINDOW
subprocess.SW_HIDE

none of which are mentioned in the module's docs:
http://docs.python.org/dev/py3k/library/subprocess.html

Cheers,
Chris
--
http://blog.rebertia.com
From: Martin P. Hellwig on
Chris Rebert wrote:
<cut>
>> Except for here:
>> http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
>
> I was referring to the following bits of the subprocess module used in
> the above code:

Me too actually :-)

> subprocess.mswindows
> subprocess.STARTUPINFO()
> subprocess.STARTF_USESHOWWINDOW
> subprocess.SW_HIDE
>
> none of which are mentioned in the module's docs:
> http://docs.python.org/dev/py3k/library/subprocess.html

Since this is platform specific stuff I would argue that it has no
business being repeated, although a link to where it is documented
elsewhere would have been nice.

--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
From: Chris Rebert on
On Thu, Oct 29, 2009 at 4:57 AM, Martin P. Hellwig
<martin.hellwig(a)dcuktec.org> wrote:
> Chris Rebert wrote:
> <cut>
>>>
>>> Except for here:
>>> http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
>>
>> I was referring to the following bits of the subprocess module used in
>> the above code:
>
> Me too actually :-)
>
>> subprocess.mswindows
>> subprocess.STARTUPINFO()
>> subprocess.STARTF_USESHOWWINDOW
>> subprocess.SW_HIDE
>>
>> none of which are mentioned in the module's docs:
>> http://docs.python.org/dev/py3k/library/subprocess.html
>
> Since this is platform specific stuff I would argue that it has no business
> being repeated, although a link to where it is documented elsewhere would
> have been nice.

True, the Windows APIs are documented but it's not mentioned at all
that they're accessible in a certain form from subprocess.
Many other stdlib modules (e.g. `os` -
http://docs.python.org/library/os.html) include and list
platform-specific functions, I don't see why subprocess should be
different.

Cheers,
Chris
--
http://blog.rebertia.com