Skip to content

Instantly share code, notes, and snippets.

@detly
Created April 26, 2015 04:04
Show Gist options
  • Save detly/4005b18705354dd74811 to your computer and use it in GitHub Desktop.
Save detly/4005b18705354dd74811 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import asyncio
import sys
import pexpect
@asyncio.coroutine
def run():
p = pexpect.spawn('./weirdness')
while True:
try:
_ = yield from p.expect_exact('\r', async=True)
except pexpect.EOF as e:
print("2. output: {:s}".format(repr(p.before)))
return
else:
print("1. output: {:s}".format(repr(p.before + p.after)))
def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
loop.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment