Commit 28a7ca85 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain
Browse files

timeout magic

parent 6594f7cb
......@@ -44,7 +44,8 @@ class BiochamKernel(Kernel):
self.comm_manager = CommManager(parent=self, kernel=self)
comm_msg_types = ['comm_open', 'comm_msg', 'comm_close']
for msg_type in comm_msg_types:
self.shell_handlers[msg_type] = getattr(self.comm_manager, msg_type)
self.shell_handlers[msg_type] = \
getattr(self.comm_manager, msg_type)
self._start_biocham()
def _start_biocham(self):
......@@ -85,7 +86,7 @@ class BiochamKernel(Kernel):
image_filenames, output = extract_image_filenames(output)
if output.startswith('ERROR:'):
status = 'error'
except:
except Exception:
self.biocham.child.kill(SIGINT)
self.biocham.run_command('a')
output = 'non-terminated command'
......@@ -152,6 +153,10 @@ class BiochamKernel(Kernel):
'text': line.strip() + '.',
'replace': False,
} for line in reversed(lines) if line.strip()]
elif magic.starstwith('timeout '):
self.timeout = int(magic[8:].split()[0])
output = 'Timeout set to ' + str(self.timeout)
payload = []
elif magic.startswith('slider '):
output = ''
payload = []
......@@ -182,7 +187,8 @@ class BiochamKernel(Kernel):
'data': {
'text/html': ''.join([
'''
<label style="float: left; padding-left: 10px; padding-right: 0px; margin-right: 0px;">{param}</label>
<label style="float: left; padding-left: 10px; padding-right: 0px;
margin-right: 0px;">{param}</label>
<label id="{param}_val_{id}"
style="float: left; margin-left: 0px; padding-left: 0px;">
={current}</label>
......@@ -237,6 +243,7 @@ class BiochamKernel(Kernel):
output = '''The available magics are:
%lsmagic\tLists available magics
%load [file.bc]\tImport a biocham file as a notebook cell
%timeout [s]\tSets the timeout for the communication with the kernel
%slider <parameter> [parameter parameter]\tCreates a slider to change \
given parameter(s) in default simulation
'''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment