environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py
def run_cell(self, raw_cell, store_history=False, silent=False):
        """Run a complete IPython cell.

        Parameters
        ----------
        raw_cell : str
          The code (including IPython code such as %magic functions) to run.
        store_history : bool
          If True, the raw and translated cell will be stored in IPython's
          history. For user code calling back into IPython's machinery, this
          should be set to False.
        silent : bool
          If True, avoid side-effets, such as implicit displayhooks, history,
          and logging.  silent=True forces store_history=False.
        """
        if (not raw_cell) or raw_cell.isspace():
            return
        
        if silent:
            store_history = False

        self.input_splitter.push(raw_cell)

        # Check for cell magics, which leave state behind.  This interface is
        # ugly, we need to do something cleaner later...  Now the logic is
        # simply that the input_splitter remembers if there was a cell magic,
        # and in that case we grab the cell body.
        if self.input_splitter.cell_magic_parts:
            self._current_cell_magic_body = \
                               ''.join(self.input_splitter.cell_magic_parts)
        cell = self.input_splitter.source_reset()

        with self.builtin_trap:
            prefilter_failed = False
            if len(cell.splitlines()) == 1:
                try:
                    # use prefilter_lines to handle trailing newlines
                    # restore trailing newline for ast.parse
                    cell = self.prefilter_manager.prefilter_lines(cell) + '\n'
                except AliasError as e:
                    error(e)
                    prefilter_failed = True
                except Exception:
                    # don't allow prefilter errors to crash IPython
                    self.showtraceback()
                    prefilter_failed = True

            # Store raw and processed history
            if store_history:
                self.history_manager.store_inputs(self.execution_count,
                                                  cell, raw_cell)
            if not silent:
                self.logger.log(cell, raw_cell)

            if not prefilter_failed:
                # don't run if prefilter failed
                cell_name = self.compile.cache(cell, self.execution_count)

                with self.display_trap:
                    try:
                        code_ast = self.compile.ast_parse(cell,
                                                          filename=cell_name)
                    except IndentationError:
                        self.showindentationerror()
                        if store_history:
                            self.execution_count += 1
                        return None
                    except (OverflowError, SyntaxError, ValueError, TypeError,
                            MemoryError):
                        self.showsyntaxerror()
                        if store_history:
                            self.execution_count += 1
                        return None
                    
                    interactivity = "none" if silent else self.ast_node_interactivity
                    self.run_ast_nodes(code_ast.body, cell_name,
                                       interactivity=interactivity)
                    
                    # Execute any registered post-execution functions.
                    # unless we are silent
                    post_exec = [] if silent else self._post_execute.iteritems()
                    
                    for func, status in post_exec:
                        if self.disable_failing_post_execute and not status:
                            continue
                        try:
                            func()
                        except KeyboardInterrupt:
                            print >> io.stderr, "\nKeyboardInterrupt"
                        except Exception:
                            # register as failing:
                            self._post_execute[func] = False
                            self.showtraceback()
                            print >> io.stderr, '\n'.join([
                                "post-execution function %r produced an error." % func,
                                "If this problem persists, you can disable failing post-exec functions with:",
                                "",
                                "    get_ipython().disable_failing_post_execute = True"
                            ])

        if store_history:
            # Write output to the database. Does nothing unless
            # history output logging is enabled.
            self.history_manager.store_output(self.execution_count)
            # Each cell is a *single* input, regardless of how many lines it has
            self.execution_count += 1
def run_cell(self, raw_cell, store_history=False, silent=False):
        if (not raw_cell) or raw_cell.isspace():
            return
        
        if silent:
            store_history = False

        self.input_splitter.push(raw_cell)

        # Check for cell magics, which leave state behind.  This interface is
        # ugly, we need to do something cleaner later...  Now the logic is
        # simply that the input_splitter remembers if there was a cell magic,
        # and in that case we grab the cell body.
        if self.input_splitter.cell_magic_parts:
            self._current_cell_magic_body = \
                               ''.join(self.input_splitter.cell_magic_parts)
        cell = self.input_splitter.source_reset()

        with self.builtin_trap:
            prefilter_failed = False
            if len(cell.splitlines()) == 1:
                try:
                    # use prefilter_lines to handle trailing newlines
                    # restore trailing newline for ast.parse
                    cell = self.prefilter_manager.prefilter_lines(cell) + '\n'
                except AliasError as e:
                    error(e)
                    prefilter_failed = True
                except Exception:
                    # don't allow prefilter errors to crash IPython
                    self.showtraceback()
                    prefilter_failed = True

            # Store raw and processed history
            if store_history:
                self.history_manager.store_inputs(self.execution_count,
                                                  cell, raw_cell)
            if not silent:
                self.logger.log(cell, raw_cell)

            if not prefilter_failed:
                # don't run if prefilter failed
                cell_name = self.compile.cache(cell, self.execution_count)

                with self.display_trap:
                    try:
                        code_ast = self.compile.ast_parse(cell,
                                                          filename=cell_name)
                    except IndentationError:
                        self.showindentationerror()
                        if store_history:
                            self.execution_count += 1
                        return None
                    except (OverflowError, SyntaxError, ValueError, TypeError,
                            MemoryError):
                        self.showsyntaxerror()
                        if store_history:
                            self.execution_count += 1
                        return None
                    
                    interactivity = "none" if silent else self.ast_node_interactivity
                    self.run_ast_nodes(code_ast.body, cell_name,
                                       interactivity=interactivity)
                    
                    # Execute any registered post-execution functions.
                    # unless we are silent
                    post_exec = [] if silent else self._post_execute.iteritems()
                    
                    for func, status in post_exec:
                        if self.disable_failing_post_execute and not status:
                            continue
                        try:
                            func()
                        except KeyboardInterrupt:
                            print >> io.stderr, "\nKeyboardInterrupt"
                        except Exception:
                            # register as failing:
                            self._post_execute[func] = False
                            self.showtraceback()
                            print >> io.stderr, '\n'.join([
                                "post-execution function %r produced an error." % func,
                                "If this problem persists, you can disable failing post-exec functions with:",
                                "",
                                "    get_ipython().disable_failing_post_execute = True"
                            ])

        if store_history:
            # Write output to the database. Does nothing unless
            # history output logging is enabled.
            self.history_manager.store_output(self.execution_count)
            # Each cell is a *single* input, regardless of how many lines it has
            self.execution_count += 1
def run_cell ( self , raw_cell , store_history = False , silent = False ) : if ( not raw_cell ) or raw_cell . isspace ( ) : return if silent : store_history = False self . input_splitter . push ( raw_cell ) # Check for cell magics, which leave state behind.  This interface is # ugly, we need to do something cleaner later...  Now the logic is # simply that the input_splitter remembers if there was a cell magic, # and in that case we grab the cell body. if self . input_splitter . cell_magic_parts : self . _current_cell_magic_body = '' . join ( self . input_splitter . cell_magic_parts ) cell = self . input_splitter . source_reset ( ) with self . builtin_trap : prefilter_failed = False if len ( cell . splitlines ( ) ) == 1 : try : # use prefilter_lines to handle trailing newlines # restore trailing newline for ast.parse cell = self . prefilter_manager . prefilter_lines ( cell ) + '\n' except AliasError as e : error ( e ) prefilter_failed = True except Exception : # don't allow prefilter errors to crash IPython self . showtraceback ( ) prefilter_failed = True # Store raw and processed history if store_history : self . history_manager . store_inputs ( self . execution_count , cell , raw_cell ) if not silent : self . logger . log ( cell , raw_cell ) if not prefilter_failed : # don't run if prefilter failed cell_name = self . compile . cache ( cell , self . execution_count ) with self . display_trap : try : code_ast = self . compile . ast_parse ( cell , filename = cell_name ) except IndentationError : self . showindentationerror ( ) if store_history : self . execution_count += 1 return None except ( OverflowError , SyntaxError , ValueError , TypeError , MemoryError ) : self . showsyntaxerror ( ) if store_history : self . execution_count += 1 return None interactivity = "none" if silent else self . ast_node_interactivity self . run_ast_nodes ( code_ast . body , cell_name , interactivity = interactivity ) # Execute any registered post-execution functions. # unless we are silent post_exec = [ ] if silent else self . _post_execute . iteritems ( ) for func , status in post_exec : if self . disable_failing_post_execute and not status : continue try : func ( ) except KeyboardInterrupt : print >> io . stderr , "\nKeyboardInterrupt" except Exception : # register as failing: self . _post_execute [ func ] = False self . showtraceback ( ) print >> io . stderr , '\n' . join ( [ "post-execution function %r produced an error." % func , "If this problem persists, you can disable failing post-exec functions with:" , "" , "    get_ipython().disable_failing_post_execute = True" ] ) if store_history : # Write output to the database. Does nothing unless # history output logging is enabled. self . history_manager . store_output ( self . execution_count ) # Each cell is a *single* input, regardless of how many lines it has self . execution_count += 1
Run a complete IPython cell.

        Parameters
        ----------
        raw_cell : str
          The code (including IPython code such as %magic functions) to run.
        store_history : bool
          If True, the raw and translated cell will be stored in IPython's
          history. For user code calling back into IPython's machinery, this
          should be set to False.
        silent : bool
          If True, avoid side-effets, such as implicit displayhooks, history,
          and logging.  silent=True forces store_history=False.
Run a complete IPython cell .