You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like there to be a method on expecters to be able to "drain" any immediately-available data. (And/or to drain through EOF, if there's a way to detect EOF.)
My use case:
Spawn (Popen) a testing script which has fairly parseable output
Wrap stdout of that process with echo=True (so output is echoed to our stdout)
Watch the process's output for specific cues, and respond to those by controlling a USB LED device (https://blink1.thingm.com/)
I currently do this using plain ol' expect. I can achieve the "output is echoed to our stdout" with just log_user 1 in expect, but since streamexpect seems to stop reading once it hits a match, my output will suddenly stop in most cases. Having a drain method which just chomps through any immediately-available data (e.g. poll until nothing comes back immediately, append that to the buffer, chomp through it, done) would let me dump out the rest of the line.
I could work around this by using a RegexSearcher for the error lines (with r'file not found:.*$' as an example) but that's just gross.
In the end I'd like to be able to do something like this:
pipe=Popen(command, shell=True, stdout=PIPE).stdoutwithstreamexpect.wrap(pipe, echo=True) asstream:
text=streamexpect.BytesSearcherstartup=streamexpect.SearcherCollection([
# Indicates the command is workingtext("Test Setup"),
# Indications that the command isn't workingtext("file not found:"),
text("Usage:")
])
match=stream.expect(startup, timeout=5)
ifmatch.match!="Test Setup": # Yes this could be improvedstream.drain() # Print out any remaining inputprint("Hit a problem.")
sys.exit(1)
The text was updated successfully, but these errors were encountered:
I'd like there to be a method on expecters to be able to "drain" any immediately-available data. (And/or to drain through EOF, if there's a way to detect EOF.)
My use case:
Popen
) a testing script which has fairly parseable outputecho=True
(so output is echoed to our stdout)I currently do this using plain ol'
expect
. I can achieve the "output is echoed to our stdout" with justlog_user 1
inexpect
, but sincestreamexpect
seems to stop reading once it hits a match, my output will suddenly stop in most cases. Having adrain
method which just chomps through any immediately-available data (e.g. poll until nothing comes back immediately, append that to the buffer, chomp through it, done) would let me dump out the rest of the line.I could work around this by using a RegexSearcher for the error lines (with
r'file not found:.*$'
as an example) but that's just gross.In the end I'd like to be able to do something like this:
The text was updated successfully, but these errors were encountered: