Show More
@@ -150,7 +150,8 b' class ProcessHandler(object):' | |||||
150 | # can set pexpect's search window to be tiny and it won't matter. |
|
150 | # can set pexpect's search window to be tiny and it won't matter. | |
151 | # We only search for the 'patterns' timeout or EOF, which aren't in |
|
151 | # We only search for the 'patterns' timeout or EOF, which aren't in | |
152 | # the text itself. |
|
152 | # the text itself. | |
153 | child = pexpect.spawn(pcmd, searchwindowsize=1) |
|
153 | #child = pexpect.spawn(pcmd, searchwindowsize=1) | |
|
154 | child = pexpect.spawn(pcmd) | |||
154 | flush = sys.stdout.flush |
|
155 | flush = sys.stdout.flush | |
155 | while True: |
|
156 | while True: | |
156 | # 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,10 +159,10 b' class ProcessHandler(object):' | |||||
158 | res_idx = child.expect_list(patterns, self.read_timeout) |
|
159 | res_idx = child.expect_list(patterns, self.read_timeout) | |
159 | print(child.before[out_size:], end='') |
|
160 | print(child.before[out_size:], end='') | |
160 | flush() |
|
161 | flush() | |
161 | # Update the pointer to what we've already printed |
|
|||
162 | out_size = len(child.before) |
|
|||
163 | if res_idx==EOF_index: |
|
162 | if res_idx==EOF_index: | |
164 | break |
|
163 | break | |
|
164 | # Update the pointer to what we've already printed | |||
|
165 | out_size = len(child.before) | |||
165 | except KeyboardInterrupt: |
|
166 | except KeyboardInterrupt: | |
166 | # We need to send ^C to the process. The ascii code for '^C' is 3 |
|
167 | # We need to send ^C to the process. The ascii code for '^C' is 3 | |
167 | # (the character is known as ETX for 'End of Text', see |
|
168 | # (the character is known as ETX for 'End of Text', see | |
@@ -173,6 +174,7 b' class ProcessHandler(object):' | |||||
173 | out_size = len(child.before) |
|
174 | out_size = len(child.before) | |
174 | child.expect_list(patterns, self.terminate_timeout) |
|
175 | child.expect_list(patterns, self.terminate_timeout) | |
175 | print(child.before[out_size:], end='') |
|
176 | print(child.before[out_size:], end='') | |
|
177 | sys.stdout.flush() | |||
176 | except KeyboardInterrupt: |
|
178 | except KeyboardInterrupt: | |
177 | # Impatient users tend to type it multiple times |
|
179 | # Impatient users tend to type it multiple times | |
178 | pass |
|
180 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now