##// END OF EJS Templates
Add flushing to stdout/stderr in system calls.
Brian Granger -
Show More
@@ -1,20 +1,22 b''
1 import sys
1 import sys
2 from subprocess import Popen, PIPE
2 from subprocess import Popen, PIPE
3 from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
3 from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
4
4
5
5
6 class ZMQInteractiveShell(InteractiveShell):
6 class ZMQInteractiveShell(InteractiveShell):
7 """A subclass of InteractiveShell for ZMQ."""
7 """A subclass of InteractiveShell for ZMQ."""
8
8
9 def system(self, cmd):
9 def system(self, cmd):
10 cmd = self.var_expand(cmd, depth=2)
10 cmd = self.var_expand(cmd, depth=2)
11 sys.stdout.flush()
12 sys.stderr.flush()
11 p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
13 p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
12 for line in p.stdout.read().split('\n'):
14 for line in p.stdout.read().split('\n'):
13 if len(line) > 0:
15 if len(line) > 0:
14 print line
16 print line
15 for line in p.stderr.read().split('\n'):
17 for line in p.stderr.read().split('\n'):
16 if len(line) > 0:
18 if len(line) > 0:
17 print line
19 print line
18 return p.wait()
20 return p.wait()
19
21
20 InteractiveShellABC.register(ZMQInteractiveShell)
22 InteractiveShellABC.register(ZMQInteractiveShell)
General Comments 0
You need to be logged in to leave comments. Login now