go install 提示

This commit is contained in:
Liang Ding 2014-10-22 21:57:21 +08:00
parent 775b11b210
commit a35f09cc02
3 changed files with 113 additions and 79 deletions

View File

@ -84,5 +84,8 @@
"start-build": "开始构建",
"build-succ": "构建成功",
"build-failed": "构建失败",
"start-install": "开始 go install",
"install-succ": "go install 成功",
"install-failed": "go install 失败",
"colon": ""
}

View File

@ -456,10 +456,38 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
return
}
if data["succ"].(bool) {
if !data["succ"].(bool) {
return
}
channelRet := map[string]interface{}{}
if nil != session.OutputWS[sid] {
// 在前端 output 中显示“开始构建”
channelRet["output"] = i18n.Get(r, "start-install").(string) + "\n"
channelRet["cmd"] = "start-install"
wsChannel := session.OutputWS[sid]
err := wsChannel.Conn.WriteJSON(&channelRet)
if nil != err {
glog.Error(err)
return
}
// 更新通道最近使用时间
wsChannel.Time = time.Now()
}
reader := io.MultiReader(stdout, stderr)
cmd.Start()
if err := cmd.Start(); nil != err {
glog.Error(err)
data["succ"] = false
return
}
go func(runningId int) {
defer util.Recover()
@ -472,7 +500,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
count, _ := reader.Read(buf)
channelRet := map[string]interface{}{}
channelRet["output"] = string(buf[:count])
channelRet["cmd"] = "go install"
if 0 != count { // 构建失败
@ -504,7 +532,6 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
file := line[:strings.Index(line, ":")]
left := line[strings.Index(line, ":")+1:]
glog.Info("left: ", left)
lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")])
msg := left[strings.Index(left, ":")+2:]
@ -519,6 +546,10 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
}
channelRet["lints"] = lints
channelRet["output"] = i18n.Get(r, "install-failed").(string) + "\n" + errOut
} else {
channelRet["output"] = i18n.Get(r, "install-succ").(string) + "\n"
}
if nil != session.OutputWS[sid] {
@ -536,7 +567,6 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
}(rand.Int())
}
}
// go get.
func GoGetHandler(w http.ResponseWriter, r *http.Request) {

View File

@ -343,6 +343,7 @@ var wide = {
break;
case 'start-build':
case 'start-install':
wide.fillOutput(data.output);
break;