Browse Source

Merge pull request 'optimization' (#121) from download-code into develop

Reviewed-by: stardust <denglf@pcl.ac.cn>
master
yuyuanshifu 4 years ago
parent
commit
1bd16b7625
3 changed files with 4 additions and 36 deletions
  1. +0
    -2
      custom/conf/app.ini.sample
  2. +0
    -4
      modules/setting/setting.go
  3. +4
    -30
      routers/repo/cloudbrain.go

+ 0
- 2
custom/conf/app.ini.sample View File

@@ -1055,8 +1055,6 @@ DEBUG_SERVER_HOST = http://192.168.202.73/
USER = cW4cMtH24eoWPE7X
PWD = 4BPmgvK2hb2Eywwyp4YZRY4B7yQf4DA.C
JOB_TYPE = debug_openi
GIT_USER = opendata
GIT_PASSWORD = pa%40123456

[decompress]
HOST = http://192.168.207.34:39987


+ 0
- 4
modules/setting/setting.go View File

@@ -438,8 +438,6 @@ var (
JobPath string
JobType string
DebugServerHost string
GitUser string
GitPassword string
)

// DateLang transforms standard language locale name to corresponding value in datetime plugin.
@@ -1115,8 +1113,6 @@ func NewContext() {
JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/")
DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73")
JobType = sec.Key("JOB_TYPE").MustString("debug_openi")
GitUser = sec.Key("GIT_USER").MustString("opendata")
GitPassword = sec.Key("GIT_PASSWORD").MustString("pa%40123456")
}

func loadInternalToken(sec *ini.Section) string {


+ 4
- 30
routers/repo/cloudbrain.go View File

@@ -1,9 +1,9 @@
package repo

import (
"code.gitea.io/gitea/modules/git"
"errors"
"os"
"os/exec"
"strconv"
"strings"
"time"
@@ -120,14 +120,10 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
uuid := form.Attachment
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath
repo := ctx.Repo.Repository
err := downloadCode(repo, codePath)
if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return
}
downloadCode(repo, codePath)

modelPath := setting.JobPath + jobName + "/model"
err = os.MkdirAll(modelPath, os.ModePerm)
err := os.MkdirAll(modelPath, os.ModePerm)
if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return
@@ -243,30 +239,8 @@ func CloudBrainStop(ctx *context.Context) {
}

func downloadCode(repo *models.Repository, codePath string) error {
/*
if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{
Bare: true,
Shared: true,
}); err != nil {
if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil {
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err)
return "", fmt.Errorf("Failed to clone repository: %s (%v)", repo.FullName(), err)
}

*/

err := os.MkdirAll(codePath, os.ModePerm)
if err != nil {
log.Error("MkdirAll failed:%v", err)
return err
}

repoAddr := repo.CloneLink().HTTPS
command := "git clone " + repoAddr[: strings.Index(repoAddr, ":") + 3] + setting.GitUser + ":" + setting.GitPassword + "@" + repoAddr[strings.Index(repoAddr, ":") + 3 :] + " " + codePath
cmd := exec.Command("/bin/bash", "-c", command)
output, err := cmd.Output()
log.Info(string(output))
if err != nil {
log.Error("exec.Command(%s) failed:%v", command, err)
return err
}



Loading…
Cancel
Save