New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seperate input and output stream #618
Comments
just to be sure everyone gets the use case. this is my ugly fix with no deeper understanding how pexpect is working. i've modified mainly the sending and reading part and inject either sys.stdin or sys.stdout wheter im sending or want to receive:
|
I would like this option for logging as well, specifically, I would like to log stdout only for spawned bash shells, otherwise my logs look like this:
which makes reading my logs unpleasant. Is there an option I'm missing? Or is a pexpect code change required for this feature? |
I found this on stackoverflow https://stackoverflow.com/questions/13590578/print-and-pexpect-logging For my problem using |
Note that you can greatly simplify your "ugly fix" by simply forwarding the read/write functions to the base class: class Child (pexpect.spawn):
def __init__ (self, timeout = 30, maxread = 2000,
searchwindowsize = None, logfile = None,
encoding = None, codec_errors = 'strict',
use_poll = False):
super().__init__ (
None,
timeout = timeout, maxread = maxread, searchwindowsize = searchwindowsize,
logfile = logfile, encoding = encoding, codec_errors = codec_errors,
use_poll = use_poll)
self.closed = False
def read_nonblocking (self, size=1, timeout=-1):
self.child_fd = sys.stdin.fileno()
return super().read_nonblocking (size, timeout)
def send (self, s):
self.child_fd = sys.stdout.fileno()
return super().send (s)
def isalive (self):
return True |
hi,
thank you for pexpect. not everyone wants to learn tcl :)
i faced this challenge:
if you want to write complex chatscripts for pppd or mock some tests where you are not the caller but you get called, there is the issue that you have 2 filedescriptors: sys.stdin and sys.stdout.
i have "hack-fixed" this issue for me but i think a good solution would be a fdspawn with 2 seperated filehandles.
or am i missing another simpler solution?
thx
The text was updated successfully, but these errors were encountered: