Created
April 26, 2015 04:04
-
-
Save detly/4005b18705354dd74811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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