##// END OF EJS Templates
Merge pull request #2184 from jasongrout/store-history...
Thomas Kluyver -
r8236:f56e91cd merge
parent child Browse files
Show More
@@ -2568,7 +2568,7 b' class InteractiveShell(SingletonConfigurable):'
2568 history. For user code calling back into IPython's machinery, this
2568 history. For user code calling back into IPython's machinery, this
2569 should be set to False.
2569 should be set to False.
2570 silent : bool
2570 silent : bool
2571 If True, avoid side-effets, such as implicit displayhooks, history,
2571 If True, avoid side-effects, such as implicit displayhooks and
2572 and logging. silent=True forces store_history=False.
2572 and logging. silent=True forces store_history=False.
2573 """
2573 """
2574 if (not raw_cell) or raw_cell.isspace():
2574 if (not raw_cell) or raw_cell.isspace():
@@ -331,6 +331,7 b' class Kernel(Configurable):'
331 content = parent[u'content']
331 content = parent[u'content']
332 code = content[u'code']
332 code = content[u'code']
333 silent = content[u'silent']
333 silent = content[u'silent']
334 store_history = content.get(u'store_history', not silent)
334 except:
335 except:
335 self.log.error("Got bad msg: ")
336 self.log.error("Got bad msg: ")
336 self.log.error("%s", parent)
337 self.log.error("%s", parent)
@@ -367,7 +368,7 b' class Kernel(Configurable):'
367 reply_content = {}
368 reply_content = {}
368 try:
369 try:
369 # FIXME: the shell calls the exception handler itself.
370 # FIXME: the shell calls the exception handler itself.
370 shell.run_cell(code, store_history=not silent, silent=silent)
371 shell.run_cell(code, store_history=store_history, silent=silent)
371 except:
372 except:
372 status = u'error'
373 status = u'error'
373 # FIXME: this code right now isn't being used yet by default,
374 # FIXME: this code right now isn't being used yet by default,
@@ -219,7 +219,7 b' class ShellSocketChannel(ZMQSocketChannel):'
219 """
219 """
220 raise NotImplementedError('call_handlers must be defined in a subclass.')
220 raise NotImplementedError('call_handlers must be defined in a subclass.')
221
221
222 def execute(self, code, silent=False,
222 def execute(self, code, silent=False, store_history=True,
223 user_variables=None, user_expressions=None, allow_stdin=None):
223 user_variables=None, user_expressions=None, allow_stdin=None):
224 """Execute code in the kernel.
224 """Execute code in the kernel.
225
225
@@ -229,7 +229,12 b' class ShellSocketChannel(ZMQSocketChannel):'
229 A string of Python code.
229 A string of Python code.
230
230
231 silent : bool, optional (default False)
231 silent : bool, optional (default False)
232 If set, the kernel will execute the code as quietly possible.
232 If set, the kernel will execute the code as quietly possible, and
233 will force store_history to be False.
234
235 store_history : bool, optional (default True)
236 If set, the kernel will store command history. This is forced
237 to be False if silent is True.
233
238
234 user_variables : list, optional
239 user_variables : list, optional
235 A list of variable names to pull from the user's namespace. They
240 A list of variable names to pull from the user's namespace. They
@@ -267,7 +272,7 b' class ShellSocketChannel(ZMQSocketChannel):'
267
272
268 # Create class for content/msg creation. Related to, but possibly
273 # Create class for content/msg creation. Related to, but possibly
269 # not in Session.
274 # not in Session.
270 content = dict(code=code, silent=silent,
275 content = dict(code=code, silent=silent, store_history=store_history,
271 user_variables=user_variables,
276 user_variables=user_variables,
272 user_expressions=user_expressions,
277 user_expressions=user_expressions,
273 allow_stdin=allow_stdin,
278 allow_stdin=allow_stdin,
@@ -158,14 +158,19 b' Message type: ``execute_request``::'
158 # A boolean flag which, if True, signals the kernel to execute
158 # A boolean flag which, if True, signals the kernel to execute
159 # this code as quietly as possible. This means that the kernel
159 # this code as quietly as possible. This means that the kernel
160 # will compile the code with 'exec' instead of 'single' (so
160 # will compile the code with 'exec' instead of 'single' (so
161 # sys.displayhook will not fire), and will *not*:
161 # sys.displayhook will not fire), forces store_history to be False,
162 # and will *not*:
162 # - broadcast exceptions on the PUB socket
163 # - broadcast exceptions on the PUB socket
163 # - do any logging
164 # - do any logging
164 # - populate any history
165 #
165 #
166 # The default is False.
166 # The default is False.
167 'silent' : bool,
167 'silent' : bool,
168
168
169 # A boolean flag which, if True, signals the kernel to populate history
170 # The default is True if silent is False. If silent is True, store_history
171 # is forced to be False.
172 'store_history' : bool,
173
169 # A list of variable names from the user's namespace to be retrieved. What
174 # A list of variable names from the user's namespace to be retrieved. What
170 # returns is a JSON string of the variable's repr(), not a python object.
175 # returns is a JSON string of the variable's repr(), not a python object.
171 'user_variables' : list,
176 'user_variables' : list,
@@ -308,7 +313,7 b' Execution counter (old prompt number)'
308 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309
314
310 The kernel has a single, monotonically increasing counter of all execution
315 The kernel has a single, monotonically increasing counter of all execution
311 requests that are made with ``silent=False``. This counter is used to populate
316 requests that are made with ``store_history=True``. This counter is used to populate
312 the ``In[n]``, ``Out[n]`` and ``_n`` variables, so clients will likely want to
317 the ``In[n]``, ``Out[n]`` and ``_n`` variables, so clients will likely want to
313 display it in some form to the user, which will typically (but not necessarily)
318 display it in some form to the user, which will typically (but not necessarily)
314 be done in the prompts. The value of this counter will be returned as the
319 be done in the prompts. The value of this counter will be returned as the
@@ -325,9 +330,9 b' Message type: ``execute_reply``::'
325 # One of: 'ok' OR 'error' OR 'abort'
330 # One of: 'ok' OR 'error' OR 'abort'
326 'status' : str,
331 'status' : str,
327
332
328 # The global kernel counter that increases by one with each non-silent
333 # The global kernel counter that increases by one with each request that
329 # executed request. This will typically be used by clients to display
334 # stores history. This will typically be used by clients to display
330 # prompt numbers to the user. If the request was a silent one, this will
335 # prompt numbers to the user. If the request did not store history, this will
331 # be the current value of the counter in the kernel.
336 # be the current value of the counter in the kernel.
332 'execution_count' : int,
337 'execution_count' : int,
333 }
338 }
General Comments 0
You need to be logged in to leave comments. Login now