##// END OF EJS Templates
Update posix process piping to use pexpect-u with a unicode interface.
Thomas Kluyver -
Show More
@@ -147,13 +147,13 b' class ProcessHandler(object):'
147 # can set pexpect's search window to be tiny and it won't matter.
147 # can set pexpect's search window to be tiny and it won't matter.
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(self.sh, args=['-c', cmd])
150 child = pexpect.spawn(self.sh, args=['-c', cmd], encoding=enc)
151 flush = sys.stdout.flush
151 flush = sys.stdout.flush
152 while True:
152 while True:
153 # res is the index of the pattern that caused the match, so we
153 # res is the index of the pattern that caused the match, so we
154 # know whether we've finished (if we matched EOF) or not
154 # know whether we've finished (if we matched EOF) or not
155 res_idx = child.expect_list(patterns, self.read_timeout)
155 res_idx = child.expect_list(patterns, self.read_timeout)
156 print(child.before[out_size:].decode(enc, 'replace'), end='')
156 print(child.before[out_size:], end='')
157 flush()
157 flush()
158 if res_idx==EOF_index:
158 if res_idx==EOF_index:
159 break
159 break
@@ -169,7 +169,7 b' class ProcessHandler(object):'
169 try:
169 try:
170 out_size = len(child.before)
170 out_size = len(child.before)
171 child.expect_list(patterns, self.terminate_timeout)
171 child.expect_list(patterns, self.terminate_timeout)
172 print(child.before[out_size:].decode(enc, 'replace'), end='')
172 print(child.before[out_size:], end='')
173 sys.stdout.flush()
173 sys.stdout.flush()
174 except KeyboardInterrupt:
174 except KeyboardInterrupt:
175 # Impatient users tend to type it multiple times
175 # Impatient users tend to type it multiple times
General Comments 0
You need to be logged in to leave comments. Login now