Форум сайта python.su
0
решил сделать скрипт для сборки Qt
global separator_string separator_string = " " def subprocess(request): print(request) p = Popen(request, stdout=PIPE, stdin = PIPE, shell= True) #p.communicate(bytes("y", 'UTF-8')) p.stdin.write("y\n".encode()) retcode = p.wait() text = p.stdout.read() print(text.decode('cp866')) print("exit", "code: %d" % retcode, sep=separator_string) return retcode ######################## request = [ "configure.exe", conf_type_link, conf_type_build, "-opensource", "-qt-zlib", "-qt-libpng", "-qt-libmng", "-qt-libjpeg", "-no-crt", "-nomake", "demos", "-nomake", "examples", "-no-qt3support", "-no-qmake", ] subprocess(request)
Отредактировано daimonkor (Май 17, 2012 12:44:56)
Офлайн
14
Не ясно, что вам нужно. Ждать завершения подпроцесса или таки не ждать?
Офлайн
0
Андрей Светловждать, процесс завершился, а wait чего-то не срабатывает
Не ясно, что вам нужно. Ждать завершения подпроцесса или таки не ждать?
Офлайн
14
А процесс таки завершается?
Офлайн
0
Андрей Светловда, если убираю wait
А процесс таки завершается?
Офлайн
221
daimonkor
называть пользовательские функции также как встроенные модули -это не оч хорошая практика
Посмотрите сюда:
john16blog.blogspot.com/2010/10/python-subprocess.html
Popen.wait()
ожидает завершения работы процесса и возвращает returncode.Предупреждение: это может вызвать блокировку(зависание), если дочерний процесс генерирует достаточное количество данных в stdout,stderr канал так что блокирует ожидание буфера канала ОС для принятия еще данных. Использование communicate() позволит избежать этого.
Офлайн
0
JOHN_16пробую использовать communicate
daimonkor
называть пользовательские функции также как встроенные модули -это не оч хорошая практика
Посмотрите сюда:
john16blog.blogspot.com/2010/10/python-subprocess.html
Popen.wait()
ожидает завершения работы процесса и возвращает returncode.Предупреждение: это может вызвать блокировку(зависание), если дочерний процесс генерирует достаточное количество данных в stdout,stderr канал так что блокирует ожидание буфера канала ОС для принятия еще данных. Использование communicate() позволит избежать этого.
Офлайн
0
global separator_string separator_string = " " def subprocess(request): print(request) p = Popen(request, stdout=PIPE, stdin = PIPE, shell= True) text = p.communicate("y\n".encode()) retcode = p.wait() print(text[0].decode('cp866')) print("exit", "code: %d" % retcode, sep=separator_string) return retcode
Configuration Qt ['configure.exe', '-shared', '-debug-and-release', '-opensource', '-qt-zlib', '-qt-libpng', '-qt-libmng', '-qt-libjpeg', '-no-crt', '-nomake', 'demos', '-nomake', 'examples', '-no-qt3support', '-no-qmake'] This is the Qt for Windows Open Source Edition. You are licensed to use this software under the terms of the GNU Lesser General Public License (LGPL) version 2.1 or the GNU General Public License (GPL) version 3. Type '3' to view the GNU General Public License version 3 (GPLv3). Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1). Type 'y' to accept this license offer. Type 'n' to decline this license offer. Do you accept the terms of the license? All the required DirectShow/Direct3D files couldn't be found. Make sure you have either the platform SDK AND the DirectShow SDK or the Windows SDK installed. If you have the DirectShow SDK installed, please make sure that you have run the <path to SDK>\SetEnv.Cmd script. vmr9.h not found dshow.h not found strmiids.lib not found dmoguids.lib not found msdmo.lib not found d3d9.h not found Environment: INCLUDE= Unset LIB= Unset PATH= C:\Qt\4.8.1\bin C:/Program Files/Java/jre6/bin/client C:/Program Files/Java/jre6/bin C:/Program Files/Java/jre6/lib/i386 C:\Program Files\ImageMagick-6.6.4-Q16 C:\Program Files\NVIDIA Corporation\PhysX\Common C:\Program Files\PC Connectivity Solution\ C:\WINDOWS\system32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\Program Files\VisualSVN\bin C:\Program Files\CMake 2.8\bin C:\Program Files\doxygen\bin C:\Program Files\Graphviz 2.28\bin C:\Program Files\TortoiseSVN\bin C:\Python32 C:\Qt\4.8.0\bin C:\Qt\4.8.1\bin C:\eclipse-SDK-3.7.2-win32\eclipse You are licensed to use this software under the terms of the GNU GPL version 3.You are licensed to use this software under the terms of the Lesser GNU LGPL version 2.1. See C:/Qt/4.8.13 or C:/Qt/4.8.1L Configuration: minimal-config small-config medium-config large-config full-config build_all debug Qt Configuration: release debug zlib png accessibility opengl s60 ipv6 script scripttools xmlpatterns multimedia audio-backend declarative native-gestures svg minimal-config small-config medium-config large-config full-config QMAKESPEC...................win32-msvc2010 (env) Architecture................windows Maketool....................nmake Debug symbols...............yes Link Time Code Generation...no Accessibility support.......yes STL support.................yes Exception support...........yes RTTI support................yes MMX support.................yes 3DNOW support...............no SSE support.................yes SSE2 support................yes IWMMXT support..............no OpenGL support..............yes OpenVG support..............no OpenSSL support.............no QtDBus support..............no QtXmlPatterns support.......yes Phonon support..............no QtMultimedia support........yes WebKit support..............yes Declarative support.........yes Declarative debugging.......yes QtScript support............yes QtScriptTools support.......yes Graphics System.............raster Qt3 compatibility...........no DirectWrite support.........no Third Party Libraries: ZLIB support............qt GIF support.............plugin TIFF support............plugin JPEG support............plugin PNG support.............yes MNG support.............plugin FreeType support........no Styles: Windows.................yes Windows XP..............no Windows Vista...........no Plastique...............yes Cleanlooks..............yes Motif...................yes CDE.....................yes Windows CE..............no Windows Mobile..........no S60.....................no Sql Drivers: ODBC....................no MySQL...................no OCI.....................no PostgreSQL..............no TDS.....................no DB2.....................no SQLite..................plugin (qt) SQLite2.................no InterBase...............no Sources are in..............C:\Qt\4.8.1 Build is done in............C:\Qt\4.8.1 Install prefix..............C:\Qt\4.8.1 Headers installed to........C:\Qt\4.8.1\include Libraries installed to......C:\Qt\4.8.1\lib Plugins installed to........C:\Qt\4.8.1\plugins Imports installed to........C:\Qt\4.8.1\imports Binaries installed to.......C:\Qt\4.8.1\bin Docs installed to...........C:\Qt\4.8.1\doc Data installed to...........C:\Qt\4.8.1 Translations installed to...C:\Qt\4.8.1\translations Examples installed to.......C:\Qt\4.8.1\examples Demos installed to..........C:\Qt\4.8.1\demos Perl not found in environment - cannot run syncqt. exit code: 2
Офлайн
0
перехожу на http://python.su/forum/topic/14616/
Офлайн