summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Silvester2014-07-30 21:27:14 -0500
committerSteven Silvester2014-07-30 21:27:14 -0500
commitcdb6fbca6a27e1c596179fa156ce4b22db3d08ba (patch)
tree35c40ea5f01aab9182ef0dbe82a15946996313e2
parenta2b8ddddc11ef25363dc5986f0ea2546f9a9e75a (diff)
downloadscilab_kernel-cdb6fbca6a27e1c596179fa156ce4b22db3d08ba.tar.gz
scilab_kernel-cdb6fbca6a27e1c596179fa156ce4b22db3d08ba.tar.bz2
scilab_kernel-cdb6fbca6a27e1c596179fa156ce4b22db3d08ba.zip
Partial implementation
-rw-r--r--octave_kernel.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/octave_kernel.py b/octave_kernel.py
index 129ce01..3f6f93e 100644
--- a/octave_kernel.py
+++ b/octave_kernel.py
@@ -1,4 +1,5 @@
from IPython.kernel.zmq.kernelbase import Kernel
+from oct2py import octave
import signal
from subprocess import check_output
@@ -30,10 +31,10 @@ class OctaveKernel(Kernel):
# Signal handlers are inherited by forked processes, and we can't easily
# reset it from the subprocess. Since kernelapp ignores SIGINT except in
# message handlers, we need to temporarily reset the SIGINT handler here
- # so that bash and its children are interruptible.
+ # so that octave and its children are interruptible.
sig = signal.signal(signal.SIGINT, signal.SIG_DFL)
try:
- self.bashwrapper = replwrap.bash()
+ self.octavewrapper = octave
finally:
signal.signal(signal.SIGINT, sig)
@@ -45,12 +46,14 @@ class OctaveKernel(Kernel):
interrupted = False
try:
- output = self.bashwrapper.run_command(code.rstrip(), timeout=None)
+ output = self.octavewrapper._eval(code.rstrip())
except KeyboardInterrupt:
- self.bashwrapper.child.sendintr()
+ self.octavewrapper._session.proc.send_signal(signal.SIGINT)
interrupted = True
- self.bashwrapper._expect_prompt()
- output = self.bashwrapper.child.before
+ # TODO: handle the output
+ output = 'Interrupted'
+ #self.bashwrapper._expect_prompt()
+ #output = self.bashwrapper.child.before
if not silent:
stream_content = {'name': 'stdout', 'data':output}
@@ -60,7 +63,9 @@ class OctaveKernel(Kernel):
return {'status': 'abort', 'execution_count': self.execution_count}
try:
- exitcode = int(self.run_command('echo $?').rstrip())
+ # TODO: handle an exit code
+ exitcode = 0
+ #exitcode = int(self.run_command('echo $?').rstrip())
except Exception:
exitcode = 1