(program string, logStderr bool)
| 179 | } |
| 180 | |
| 181 | func (s *pythonExecutor) runProgram(program string, logStderr bool) error { |
| 182 | cmd := sqlflowCmd(s.Cwd, s.Db.DriverName) |
| 183 | cmd.Stdin = bytes.NewBufferString(program) |
| 184 | |
| 185 | errorLog, e := s.runCommand(cmd, nil, logStderr) |
| 186 | if e != nil { |
| 187 | // return the diagnostic message |
| 188 | sub := rePyDiagnostics.FindStringSubmatch(errorLog) |
| 189 | if len(sub) == 2 { |
| 190 | return fmt.Errorf("%s", sub[1]) |
| 191 | } |
| 192 | // if no diagnostic message, return the full stack trace |
| 193 | return fmt.Errorf("failed: %v\n%sGenerated Code:%[2]s\n%s\n%[2]sOutput%[2]s\n%[4]v", e, "==========", program, errorLog) |
| 194 | } |
| 195 | return nil |
| 196 | } |
| 197 | |
| 198 | func (s *pythonExecutor) runCommand(cmd *exec.Cmd, context map[string]string, logStderr bool) (string, error) { |
| 199 | cw := &logChanWriter{wr: s.Writer} |
no test coverage detected