|
18 | 18 |
|
19 | 19 | from IPython.display import Image
|
20 | 20 | from metakernel import MetaKernel, ExceptionWrapper
|
| 21 | +from wurlitzer import pipes |
21 | 22 |
|
22 | 23 | from . import __version__
|
23 | 24 |
|
24 |
| -try: |
25 |
| - from .wurlitzer import Wurlitzer |
26 |
| -except ImportError: |
27 |
| - Wurlitzer = None |
28 |
| - |
29 | 25 |
|
30 | 26 | class _PseudoStream:
|
31 | 27 |
|
@@ -88,10 +84,7 @@ def do_execute_direct(self, code):
|
88 | 84 | self._matlab.get(0., "defaultfigureposition")[0][2:])
|
89 | 85 | self.handle_plot_settings()
|
90 | 86 |
|
91 |
| - if Wurlitzer: |
92 |
| - retval = self._execute_async(code) |
93 |
| - else: |
94 |
| - retval = self._execute_sync(code) |
| 87 | + retval = self._execute_async(code) |
95 | 88 |
|
96 | 89 | settings = self._validated_plot_settings
|
97 | 90 | if settings["backend"] == "inline":
|
@@ -245,8 +238,8 @@ def do_shutdown(self, restart):
|
245 | 238 |
|
246 | 239 | def _execute_async(self, code):
|
247 | 240 | try:
|
248 |
| - with Wurlitzer(_PseudoStream(partial(self.Print, end="")), |
249 |
| - _PseudoStream(partial(self.Error, end=""))): |
| 241 | + with pipes(stdout=_PseudoStream(partial(self.Print, end="")), |
| 242 | + stderr=_PseudoStream(partial(self.Error, end=""))): |
250 | 243 | future = self._matlab.eval(code, nargout=0, async=True)
|
251 | 244 | future.result()
|
252 | 245 | except (SyntaxError, MatlabExecutionError, KeyboardInterrupt) as exc:
|
|
0 commit comments