Show More
@@ -88,7 +88,7 b' support it. Pexpect is intended for UNIX-like operating systems.""")' | |||||
88 | __version__ = '2.6.dev' |
|
88 | __version__ = '2.6.dev' | |
89 | version = __version__ |
|
89 | version = __version__ | |
90 | version_info = (2,6,'dev') |
|
90 | version_info = (2,6,'dev') | |
91 | __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'which', |
|
91 | __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'spawnb', 'run', 'which', | |
92 | 'split_command_line', '__version__'] |
|
92 | 'split_command_line', '__version__'] | |
93 |
|
93 | |||
94 | # Exception classes used by this module. |
|
94 | # Exception classes used by this module. |
@@ -148,16 +148,16 b' class ProcessHandler(object):' | |||||
148 | # We only search for the 'patterns' timeout or EOF, which aren't in |
|
148 | # We only search for the 'patterns' timeout or EOF, which aren't in | |
149 | # the text itself. |
|
149 | # the text itself. | |
150 | #child = pexpect.spawn(pcmd, searchwindowsize=1) |
|
150 | #child = pexpect.spawn(pcmd, searchwindowsize=1) | |
151 | try: |
|
151 | if hasattr(pexpect, 'spawnb'): | |
152 |
child = pexpect.spawn(self.sh, args=['-c', cmd] |
|
152 | child = pexpect.spawnb(self.sh, args=['-c', cmd]) # Pexpect-U | |
153 |
e |
|
153 | else: | |
154 |
child = pexpect.spawn(self.sh, args=['-c', cmd]) |
|
154 | child = pexpect.spawn(self.sh, args=['-c', cmd]) # Vanilla Pexpect | |
155 | flush = sys.stdout.flush |
|
155 | flush = sys.stdout.flush | |
156 | while True: |
|
156 | while True: | |
157 | # res is the index of the pattern that caused the match, so we |
|
157 | # res is the index of the pattern that caused the match, so we | |
158 | # know whether we've finished (if we matched EOF) or not |
|
158 | # know whether we've finished (if we matched EOF) or not | |
159 | res_idx = child.expect_list(patterns, self.read_timeout) |
|
159 | res_idx = child.expect_list(patterns, self.read_timeout) | |
160 |
print |
|
160 | print(child.before[out_size:].decode(enc, 'replace'), end='') | |
161 | flush() |
|
161 | flush() | |
162 | if res_idx==EOF_index: |
|
162 | if res_idx==EOF_index: | |
163 | break |
|
163 | break | |
@@ -173,7 +173,7 b' class ProcessHandler(object):' | |||||
173 | try: |
|
173 | try: | |
174 | out_size = len(child.before) |
|
174 | out_size = len(child.before) | |
175 | child.expect_list(patterns, self.terminate_timeout) |
|
175 | child.expect_list(patterns, self.terminate_timeout) | |
176 |
print |
|
176 | print(child.before[out_size:].decode(enc, 'replace'), end='') | |
177 | sys.stdout.flush() |
|
177 | sys.stdout.flush() | |
178 | except KeyboardInterrupt: |
|
178 | except KeyboardInterrupt: | |
179 | # Impatient users tend to type it multiple times |
|
179 | # Impatient users tend to type it multiple times |
General Comments 0
You need to be logged in to leave comments.
Login now