This is re: replicating an existing Fabric feature allowing users to insert their own stream objects to be used in place of the default writing to sys.std(out|err).
It's tougher here because while the "direct", non-pty-using use case isn't hard, pty use is currently difficult as we use pexpect right now and it's a reasonably gross, not written to be extended, etc.
There's a couple clear options:
- Try extending
pexpect anyway - the core spot that MUST be overridden isn't actually that long of a function and while it is __sekrit that still should be overrideable within a subclass.
- Testing will still be gross but I've done most of the work for that already, so eh.
- Attempt to identify only the bits of
pexpect we truly need, and replicate those in our own module (which can then be written to be more testable and of course, to have explicit stream control).
- Going by the investigation I did for test mocking, it boils down to use of the stdlib
pty module, forking, running os.execve, and then select.select on the FDs involved.
- Maybe not easy, and we'd lose (or eventually reimplement) a lot of the corner/edge cases that
pexpect handles (such as lots of nasty Solaris stuff) - but maybe worthwhile?
This is re: replicating an existing Fabric feature allowing users to insert their own stream objects to be used in place of the default writing to
sys.std(out|err).It's tougher here because while the "direct", non-pty-using use case isn't hard, pty use is currently difficult as we use
pexpectright now and it's a reasonably gross, not written to be extended, etc.There's a couple clear options:
pexpectanyway - the core spot that MUST be overridden isn't actually that long of a function and while it is__sekritthat still should be overrideable within a subclass.pexpectwe truly need, and replicate those in our own module (which can then be written to be more testable and of course, to have explicit stream control).ptymodule, forking, runningos.execve, and thenselect.selecton the FDs involved.pexpecthandles (such as lots of nasty Solaris stuff) - but maybe worthwhile?