summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-12-13 13:15:11 +0000
committerNick White <git@njw.name>2019-12-13 13:15:11 +0000
commitf36889e67c916b4518750ac4167a8192fca958b4 (patch)
tree3375fb014754a4de00144872ebe276e6d325bc0b
parentad2eaa283b7e06344c6fdc55fe441c88f00e0e94 (diff)
Print stdout and stderr output when tesseract fails
-rw-r--r--cmd/bookpipeline/main.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/bookpipeline/main.go b/cmd/bookpipeline/main.go
index aa6853f..0d310f1 100644
--- a/cmd/bookpipeline/main.go
+++ b/cmd/bookpipeline/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "bytes"
"errors"
"flag"
"fmt"
@@ -171,12 +172,15 @@ func ocr(training string) func(chan string, chan string, chan error, *log.Logger
logger.Println("OCRing", path)
name := strings.Replace(path, ".png", "", 1)
cmd := exec.Command("tesseract", "-l", training, path, name, "hocr")
+ var stdout, stderr bytes.Buffer
+ cmd.Stdout = &stdout
+ cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
for range toocr {
} // consume the rest of the receiving channel so it isn't blocked
close(up)
- errc <- errors.New(fmt.Sprintf("Error ocring %s: %s", path, err))
+ errc <- errors.New(fmt.Sprintf("Error ocring %s: %s\nStdout: %s\nStderr: %s\n", path, err, stdout.String(), stderr.String()))
return
}
up <- name + ".hocr"