Commit 2b341845 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d3bef22e
......@@ -42,8 +42,8 @@ import (
type TreeGen struct {
zurl string
pysrv *exec.Cmd // spawned `treegen trees`
pyin *io.PipeWriter // input to pysrv
pyoutRaw *io.PipeReader // output from pysrv
pyin io.WriteCloser // input to pysrv
pyoutRaw io.ReadCloser // output from pysrv
pyout *bufio.Reader // buffered ^^^
treeRoot zodb.Oid // oid of the tree treegen works on
head zodb.Tid // last made commit
......@@ -56,8 +56,14 @@ func StartTreeGen(zurl string) (_ *TreeGen, err error) {
// spawn `treegen trees`
tg := &TreeGen{zurl: zurl}
tg.pysrv = exec.Command("./testprog/treegen.py", "trees")
tg.pysrv.Stdin, tg.pyin = io.Pipe()
tg.pyoutRaw, tg.pysrv.Stdout = io.Pipe()
tg.pyin, err = tg.pysrv.StdinPipe()
if err != nil {
return nil, err
}
tg.pyoutRaw, err = tg.pysrv.StdoutPipe()
if err != nil {
return nil, err
}
tg.pyout = bufio.NewReader(tg.pyoutRaw)
tg.pysrv.Stderr = os.Stderr // no redirection
......@@ -75,6 +81,9 @@ func StartTreeGen(zurl string) (_ *TreeGen, err error) {
defer xerr.Context(&err, "handshake")
start, err := tg.pyout.ReadString('\n')
if err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return nil, err
}
defer xerr.Context(&err, "invalid start %q")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment