Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2314801
  • 博文数量: 527
  • 博客积分: 10343
  • 博客等级: 上将
  • 技术积分: 5565
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-26 23:05
文章分类

全部博文(527)

文章存档

2014年(4)

2012年(13)

2011年(19)

2010年(91)

2009年(136)

2008年(142)

2007年(80)

2006年(29)

2005年(13)

我的朋友

分类: LINUX

2012-02-24 18:00:51

import os,time,thread
import vim
import subprocess

def child(tid):
    pip = subprocess.Popen(['/home/zrf/test.sh'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    while True:
        pip.poll()
        if pip.returncode != None:
            break
        line = pip.stdout.readline()

        # Store current window
        cur_win = vim.eval("winnr()")
        # Switch to the last window
        vim.command( vim.eval("winnr('$')") + "wincmd w" )
        vim.current.buffer.append(line)
        vim.command("redraw | $")
        # Restore the origin window
        vim.command( cur_win + "wincmd w")
        #time.sleep(0.1)

    # Store current window
    cur_win = vim.eval("winnr()")
    # Switch to the last window
    vim.command( vim.eval("winnr('$')") + "wincmd w" )
    vim.current.buffer.append("===== Finished =====")
    vim.command("redraw | $")
    # Restore the origin window
    vim.command( cur_win + "wincmd w")

thread.start_new(child, (1,))

阅读(2163) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~