Add more error handler
This commit is contained in:
parent
b311a41dc7
commit
9b49c6da05
2 changed files with 100 additions and 82 deletions
|
|
@ -197,11 +197,11 @@ func (s *Server) createHandler() {
|
|||
|
||||
// locking
|
||||
if !pyAPIhandler(w, r) {
|
||||
s.taoLogger.Log.Warn("Merge - user tried to access while another user is requesting merge",
|
||||
zap.String("user", r.Context().Value("user").(*models.User).Name))
|
||||
s.taoLogger.Log.Warn("Merge - u tried to access while another u is requesting merge",
|
||||
zap.String("u", r.Context().Value("u").(*models.User).Name))
|
||||
return
|
||||
} else {
|
||||
s.taoLogger.Log.Debug("Merge - user has access", zap.String("user", r.Context().Value("user").(*models.User).Name))
|
||||
s.taoLogger.Log.Debug("Merge - u has access", zap.String("u", r.Context().Value("u").(*models.User).Name))
|
||||
}
|
||||
|
||||
var targetMap map[string]interface{}
|
||||
|
|
@ -234,27 +234,27 @@ func (s *Server) createHandler() {
|
|||
dev_path := repo_path + dev_version + ".json"
|
||||
|
||||
// Get who's requesting
|
||||
user := r.Context().Value("user").(*models.User)
|
||||
s.taoLogger.Log.Info("Request merge by", zap.String("user", user.Name))
|
||||
u := r.Context().Value("u").(*models.User)
|
||||
s.taoLogger.Log.Info("Request merge by", zap.String("u", u.Name))
|
||||
|
||||
// lookup for python exec
|
||||
py_exec, err := exec.LookPath("python")
|
||||
pyExec, err := exec.LookPath("python")
|
||||
if err != nil {
|
||||
s.taoLogger.Log.Fatal("Python error: ", zap.Error(err))
|
||||
} else {
|
||||
py_exec, err = filepath.Abs(py_exec)
|
||||
pyExec, err = filepath.Abs(pyExec)
|
||||
}
|
||||
|
||||
s.taoLogger.Log.Info("Found python exec: ", zap.String("PythonPath", py_exec))
|
||||
s.taoLogger.Log.Info("Found python exec: ", zap.String("PythonPath", pyExec))
|
||||
// target api file
|
||||
merge_api, api_err := os.Open("./python_api/merge_recipe.py")
|
||||
mergeApi, api_err := os.Open("./python_api/merge_recipe.py")
|
||||
if api_err != nil {
|
||||
s.taoLogger.Log.Fatal("Merge request failed. Python api error: ", zap.String("ApiErr", api_err.Error()))
|
||||
}
|
||||
defer merge_api.Close()
|
||||
defer mergeApi.Close()
|
||||
// log.Println("Locate python api", merge_api.Name())
|
||||
s.taoLogger.Log.Info("Locate python api", zap.String("ApiName", merge_api.Name()))
|
||||
cmd := exec.Command(py_exec, merge_api.Name(), "merge", master_path, dev_path, output_path, changelog_path, "", user.Name)
|
||||
s.taoLogger.Log.Info("Locate python api", zap.String("ApiName", mergeApi.Name()))
|
||||
cmd := exec.Command(pyExec, mergeApi.Name(), "merge", master_path, dev_path, output_path, changelog_path, "", u.Name)
|
||||
|
||||
// log.Println("Run merge command", cmd)
|
||||
s.taoLogger.Log.Info("Merge", zap.String("master", master_path), zap.String("dev", dev_path), zap.String("output", output_path))
|
||||
|
|
@ -464,7 +464,7 @@ func (s *Server) createHandler() {
|
|||
rr.Route(r)
|
||||
|
||||
// Material Router
|
||||
mr := routers.NewMaterialRouter(s.data)
|
||||
mr := routers.NewMaterialRouter(s.data, s.taoLogger)
|
||||
mr.Route(r)
|
||||
|
||||
// User Router
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue