Merge pull request #2 from blink1073/master

Fix handling of exitcode, name of "payload" key, add stub for shutdown.
main
Thomas Kluyver 11 years ago
commit 5dd2722d03

@ -1,5 +1,6 @@
from IPython.kernel.zmq.kernelbase import Kernel from IPython.kernel.zmq.kernelbase import Kernel
from pexpect import replwrap from pexpect import replwrap
import pexpect
import signal import signal
from subprocess import check_output from subprocess import check_output
@ -41,7 +42,7 @@ class BashKernel(Kernel):
allow_stdin=False): allow_stdin=False):
if not code.strip(): if not code.strip():
return {'status': 'ok', 'execution_count': self.execution_count, return {'status': 'ok', 'execution_count': self.execution_count,
'payloads': [], 'user_expressions': {}} 'payload': [], 'user_expressions': {}}
interrupted = False interrupted = False
try: try:
@ -51,6 +52,9 @@ class BashKernel(Kernel):
interrupted = True interrupted = True
self.bashwrapper._expect_prompt() self.bashwrapper._expect_prompt()
output = self.bashwrapper.child.before output = self.bashwrapper.child.before
except pexpect.EOF:
# TODO: how do we shut down gracefully here?
output = ''
if not silent: if not silent:
stream_content = {'name': 'stdout', 'data': output} stream_content = {'name': 'stdout', 'data': output}
@ -60,7 +64,7 @@ class BashKernel(Kernel):
return {'status': 'abort', 'execution_count': self.execution_count} return {'status': 'abort', 'execution_count': self.execution_count}
try: try:
exitcode = int(self.run_command('echo $?').rstrip()) exitcode = int(self.bashwrapper.run_command('echo $?').rstrip())
except Exception: except Exception:
exitcode = 1 exitcode = 1
@ -69,7 +73,7 @@ class BashKernel(Kernel):
'ename': '', 'evalue': str(exitcode), 'traceback': []} 'ename': '', 'evalue': str(exitcode), 'traceback': []}
else: else:
return {'status': 'ok', 'execution_count': self.execution_count, return {'status': 'ok', 'execution_count': self.execution_count,
'payloads': [], 'user_expressions': {}} 'payload': [], 'user_expressions': {}}
if __name__ == '__main__': if __name__ == '__main__':
from IPython.kernel.zmq.kernelapp import IPKernelApp from IPython.kernel.zmq.kernelapp import IPKernelApp

Loading…
Cancel
Save