Уведомления

Группа в Telegram: @pythonsu

#1 Май 17, 2012 12:44:13

daimonkor
Зарегистрирован: 2012-05-07
Сообщения: 12
Репутация: +  0  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

решил сделать скрипт для сборки 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)

проблема состоит в том, что p.wait() не отпускает процесс, если убрать эту строчку работает, но как бы не логично, я жду пока процесс закончит свою работу. Ка исправить?

Отредактировано daimonkor (Май 17, 2012 12:44:56)

Офлайн

#2 Май 17, 2012 13:20:38

Андрей Светлов
От:
Зарегистрирован: 2007-05-15
Сообщения: 3137
Репутация: +  14  -
Профиль   Адрес электронной почты  

subrocess configure Qt проблема с wait()

Не ясно, что вам нужно. Ждать завершения подпроцесса или таки не ждать?



Офлайн

#3 Май 17, 2012 13:43:29

daimonkor
Зарегистрирован: 2012-05-07
Сообщения: 12
Репутация: +  0  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

Андрей Светлов
Не ясно, что вам нужно. Ждать завершения подпроцесса или таки не ждать?
ждать, процесс завершился, а wait чего-то не срабатывает

Офлайн

#4 Май 17, 2012 21:25:57

Андрей Светлов
От:
Зарегистрирован: 2007-05-15
Сообщения: 3137
Репутация: +  14  -
Профиль   Адрес электронной почты  

subrocess configure Qt проблема с wait()

А процесс таки завершается?



Офлайн

#5 Май 17, 2012 21:40:39

daimonkor
Зарегистрирован: 2012-05-07
Сообщения: 12
Репутация: +  0  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

Андрей Светлов
А процесс таки завершается?
да, если убираю wait

Офлайн

#6 Май 18, 2012 03:41:26

JOHN_16
От: Россия, Петропавловск-Камчатск
Зарегистрирован: 2010-03-22
Сообщения: 3292
Репутация: +  221  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

daimonkor
называть пользовательские функции также как встроенные модули -это не оч хорошая практика

Посмотрите сюда:
john16blog.blogspot.com/2010/10/python-subprocess.html

Popen.wait()
ожидает завершения работы процесса и возвращает returncode.Предупреждение: это может вызвать блокировку(зависание), если дочерний процесс генерирует достаточное количество данных в stdout,stderr канал так что блокирует ожидание буфера канала ОС для принятия еще данных. Использование communicate() позволит избежать этого.



_________________________________________________________________________________
полезный блог о python john16blog.blogspot.com

Офлайн

#7 Май 18, 2012 10:33:49

daimonkor
Зарегистрирован: 2012-05-07
Сообщения: 12
Репутация: +  0  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

JOHN_16
daimonkor
называть пользовательские функции также как встроенные модули -это не оч хорошая практика

Посмотрите сюда:
john16blog.blogspot.com/2010/10/python-subprocess.html

Popen.wait()
ожидает завершения работы процесса и возвращает returncode.Предупреждение: это может вызвать блокировку(зависание), если дочерний процесс генерирует достаточное количество данных в stdout,stderr канал так что блокирует ожидание буфера канала ОС для принятия еще данных. Использование communicate() позволит избежать этого.
пробую использовать communicate

Офлайн

#8 Май 18, 2012 10:52:35

daimonkor
Зарегистрирован: 2012-05-07
Сообщения: 12
Репутация: +  0  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

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
почему exit code: 2?????
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

Офлайн

#9 Май 18, 2012 11:02:38

daimonkor
Зарегистрирован: 2012-05-07
Сообщения: 12
Репутация: +  0  -
Профиль   Отправить e-mail  

subrocess configure Qt проблема с wait()

перехожу на http://python.su/forum/topic/14616/

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version