On Sunday, December 29, 2013 10:50:31 PM UTC-8, Volker Braun wrote:
>
> This is similar to http://trac.sagemath.org/15440, the problem boils down
> to: The expect pattern must(!) trigger at a place where all input has been
> eaten. Including newline/spaces. If not then there is still input coming
> into the subprocess, and the echo of that further input will show up at
> random places in the output stream.
>
I don't think that's the issue here. The problem here seems to be that the
subprocess sends output before the pty is done echoing. That doesn't seem
to within pexpect's control: it's the subprocess that's too fast. Actually,
it seems to me that the pty is being a bit careless: shouldn't it make sure
that it's done echoing before it actually delivers the character to the
process? Particularly because the "\r\n" that the pty make part of its echo
is actually invented by the pty. Is the problem that the pty doesn't flush
before delivering the input to the subprocess?
Anyway, if we would be able to turn off echoing altogether, we'd be able to
get rid of a lot of problems.For instance, in the example above, when I do
sage: import pexpect
sage: child=pexpect.spawn("env ./myecho")
sage: child.setecho(0)
sage: child.expect('prompt:')
0
sage: child.sendline('hiho')
5
sage: child.readline()
"received 'hiho'\r\n"
we see no echoed input any more. In particular there isn't an extra "\r\n"
that can go astray. With singular we can perhaps do:
sage: import pexpect
sage: child=pexpect.spawn("Singular -t")
sage: child.setecho(0)
sage: child.expect("> ")
0
sage: child.sendline("1+2;")
5
sage: child.readline()
'3\r\n'
Note that we did not see "1+2;\r\n" echoed to us!
Hopefully the other systems also have a way of turning of echoing (it seems
necessary to include the -t option: otherwise Singular starts setting some
terminal options of its own, which seems to make it impossible to turn off
echoing.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.