专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Perl/Python

还是关于子进程的有关问题。唉

发布时间:2011-06-29 20:10:54 文章来源:www.iduyao.cn 采编人员:星星草
还是关于子进程的问题。。唉!
不知道大家是否了解ruby on rails框架,这个安装有点麻烦,我就写了个自动安装和卸载的脚本,其中卸载的代码如下:
Python code

import subprocess
DEBUG = True

def Uninstallation(filename):
    try:
        print('开始卸载'+filename)
        cmd=['gem','uninstall',filename]
        if DEBUG:
            print('正在执行卸载'+filename)        
        fd = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
        #查看子进程输出
        stdout_tmp = fd.stdout.read()
        stdout = stdout_tmp.decode()
        print(stdout)
        print('已完成卸载'+filename+'\n')
    except Exception as e:
        print('卸载'+filename+'过程遇到问题,请重新卸载')
        print(e)
        exit()

if __name__ == '__main__':
    Uninstallation('rails')
    Uninstallation('activeresource')
    Uninstallation('actionmailer')
    Uninstallation('actionpack')
    Uninstallation('activerecord')
    Uninstallation('activesupport')
    Uninstallation('mysql')
    Uninstallation('rack')
    Uninstallation('rake')
    print('Ruby On Rails 所有组件都已成功卸载')


可是遇到点问题,当卸载rails和rake的时候,会出现这个提示,需要手动输入y再按回车才会继续:

subprocess.Popen()函数没有办法在子进程运行到一半的时候再给它输入参数,并且由于子进程没运行完这个提示也不会出现在pythonGUI上,虽然只要输入y再按回车便可继续,但用户看起来肯定是认为卡死了。
该怎么解决这个问题呢?

------解决方案--------------------
看不到图片。
subprocess.Popen()函数没有办法在子进程运行到一半的时候再给它输入参数?
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: