From: Timothy W. Grove on 27 Jul 2010 19:12 I am using the following code to hide the console window when launching a subprocess under Windows. startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE self.mplayer = Popen(args, bufsize=0, #unbufferred stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False, universal_newlines=True, startupinfo=startupinfo ) This worked okay in using the subprocess module under python 2.6, but under python 2.7 I get the error: Exception in thread Thread-1: Traceback (most recent call last): File "threading.pyo", line 530, in __bootstrap_inner File "gui\mplayer_ctrl.pyo", line 93, in run AttributeError: 'module' object has no attribute 'STARTF_USESHOWWINDOW' Anything changed between python versions to account for this? Best regards, Tim
From: Chris Rebert on 27 Jul 2010 19:36 On Tue, Jul 27, 2010 at 4:12 PM, Timothy W. Grove <tim_grove(a)sil.org> wrote: > I am using the following code to hide the console window when launching a > subprocess under Windows. > > Â Â Â startupinfo = subprocess.STARTUPINFO() > Â Â Â startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW > Â Â Â startupinfo.wShowWindow = subprocess.SW_HIDE > > Â Â Â self.mplayer = Popen(args, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufsize=0, #unbufferred > Â Â Â Â Â Â Â Â Â Â Â Â Â Â stdin=PIPE, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â stdout=PIPE, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â stderr=PIPE, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â close_fds=False, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â universal_newlines=True, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â startupinfo=startupinfo > Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) > > This worked okay in using the subprocess module under python 2.6, but under > python 2.7 I get the error: > > Exception in thread Thread-1: > Traceback (most recent call last): > Â File "threading.pyo", line 530, in __bootstrap_inner > Â File "gui\mplayer_ctrl.pyo", line 93, in run > AttributeError: 'module' object has no attribute 'STARTF_USESHOWWINDOW' > > Anything changed between python versions to account for this? Yes, apparently the code importing that stuff got removed: http://svn.python.org/view/python/tags/r27/Lib/subprocess.py?r1=79064&r2=82504 FWIW, STARTUPINFO(), STARTF_USESHOWWINDOW, and SW_HIDE were/are undocumented in both Python versions and thus shouldn't be relied upon. They can be accessed via Python's win32-specific modules instead (see diff). Cheers, Chris -- http://blog.rebertia.com
|
Pages: 1 Prev: urllib timeout Next: The Miracle and Challenge of the Quran |