Пример #1
0
    def __init__(self, **kwargs):

        MetaKernel.__init__(self, **kwargs)
        #JSROOT.enableJSVis()
        #JSROOT.enableJSVisDebug()
        JSROOT.setStyle()
        JSROOT.LoadDrawer()
        self.ioHandler = GetIOHandler()
        self.Executor = GetExecutor()
        self.Declarer = GetDeclarer()  #required for %%cpp -d magic
        self.ACLiC = ACLiC
        self.magicloader = MagicLoader(self)
        self.parser = Parser(self.identifier_regex, self.func_call_regex,
                             self.magic_prefixes, self.help_suffix)
        self.completer = CppCompleter()
        self.completer.activate()
Пример #2
0
 def __init__(self,**kwargs):
     
     MetaKernel.__init__(self,**kwargs)
     #JSROOT.enableJSVis()
     #JSROOT.enableJSVisDebug()
     JSROOT.setStyle()
     JSROOT.LoadDrawer()
     self.ioHandler = GetIOHandler()
     self.Executor  = GetExecutor()
     self.Declarer  = GetDeclarer()#required for %%cpp -d magic
     self.ACLiC     = ACLiC
     self.magicloader = MagicLoader(self)        
     self.parser = Parser(self.identifier_regex, self.func_call_regex,
                          self.magic_prefixes, self.help_suffix)
     self.completer = CppCompleter()
     self.completer.activate()
Пример #3
0
class ROOTKernel(MetaKernel):
    implementation = 'ROOT'
    implementation_version = '1.0'
    language = 'c++'
    language_version = '0.1'
    language_info = {
        'name': 'c++',
        'codemirror_mode': 'text/x-c++src',
        'mimetype': ' text/x-c++src',
        'file_extension': '.C'
    }
    banner = "CERN's ROOT Kernel(JuPyROOT) %s" % ROOT.gROOT.GetVersion()

    def __init__(self, **kwargs):

        MetaKernel.__init__(self, **kwargs)
        #JSROOT.enableJSVis()
        #JSROOT.enableJSVisDebug()
        JSROOT.setStyle()
        JSROOT.LoadDrawer()
        self.ioHandler = GetIOHandler()
        self.Executor = GetExecutor()
        self.Declarer = GetDeclarer()  #required for %%cpp -d magic
        self.ACLiC = ACLiC
        self.magicloader = MagicLoader(self)
        self.parser = Parser(self.identifier_regex, self.func_call_regex,
                             self.magic_prefixes, self.help_suffix)
        self.completer = CppCompleter()
        self.completer.activate()

    def get_completions(self, info):
        if _debug: Debug(info)
        return self.completer._completeImpl(info['code'])

    def do_execute_direct(self, code, silent=False):

        if not code.strip():
            return

        status = 'ok'
        traceback = None
        std_out = ""
        std_err = ""
        try:
            Debug(code)
            self.ioHandler.clear()
            self.ioHandler.InitCapture()
            root_status = self.Executor(str(code))
            self.ioHandler.EndCapture()

            std_out = self.ioHandler.getStdout()
            std_err = self.ioHandler.getStderr()

            canvaslist = ROOT.gROOT.GetListOfCanvases()
            if canvaslist:
                for canvas in canvaslist:
                    if canvas.IsDrawn():
                        self.drawer = JSROOT.CanvasDrawer(canvas)
                        if self.drawer._canJsDisplay():
                            self.Display(HTML(self.drawer.JsCode()))
                        else:
                            self.Display(self.drawer.PngImage())
                        canvas.ResetDrawn()

        except KeyboardInterrupt:
            self.interpreter.gROOT.SetInterrupt()
            status = 'interrupted'
            self.ioHandler.EndCapture()
            std_out = self.ioHandler.getStdout()
            std_err = self.ioHandler.getStderr()
        if not silent:
            ## Send output on stdout
            stream_content_stdout = {'name': 'stdout', 'text': std_out}
            self.send_response(self.iopub_socket, 'stream',
                               stream_content_stdout)
            if std_err != "":
                stream_content_stderr = {'name': 'stderr', 'text': std_err}
                self.send_response(self.iopub_socket, 'stream',
                                   stream_content_stderr)

        reply = {
            'status': status,
            'execution_count': self.execution_count,
            'payload': [],
            'user_expressions': {},
        }

        if status == 'interrupted':
            pass
        elif status == 'error':
            err = {
                'ename': 'ename',
                'evalue': 'evalue',
                'traceback': traceback,
            }
            self.send_response(self.iopub_socket, 'error', err)
            reply.update(err)
        elif status == 'ok':
            pass
        else:
            raise ValueError("Invalid status: %r" % status)
Пример #4
0
class ROOTKernel(MetaKernel):
    implementation = 'ROOT'
    implementation_version = '1.0'
    language = 'c++'
    language_version = '0.1'
    language_info = {'name': 'c++',
                     'codemirror_mode': 'text/x-c++src',
                     'mimetype': ' text/x-c++src',
                     'file_extension': '.C'}
    banner = "CERN's ROOT Kernel(JuPyROOT) %s"%ROOT.gROOT.GetVersion()
    
    def __init__(self,**kwargs):
        
        MetaKernel.__init__(self,**kwargs)
        #JSROOT.enableJSVis()
        #JSROOT.enableJSVisDebug()
        JSROOT.setStyle()
        JSROOT.LoadDrawer()
        self.ioHandler = GetIOHandler()
        self.Executor  = GetExecutor()
        self.Declarer  = GetDeclarer()#required for %%cpp -d magic
        self.ACLiC     = ACLiC
        self.magicloader = MagicLoader(self)        
        self.parser = Parser(self.identifier_regex, self.func_call_regex,
                             self.magic_prefixes, self.help_suffix)
        self.completer = CppCompleter()
        self.completer.activate()
        

    def get_completions(self, info):
        if _debug :Debug(info)
        return self.completer._completeImpl(info['code'])
        
    def do_execute_direct(self, code, silent=False):
        
        if not code.strip():
            return

        status = 'ok'
        traceback = None
        std_out=""
        std_err=""
        try:
            Debug(code)            
            self.ioHandler.clear()
            self.ioHandler.InitCapture()
            root_status = self.Executor(str(code))
            self.ioHandler.EndCapture()
            
            std_out = self.ioHandler.getStdout()
            std_err = self.ioHandler.getStderr()
            
            canvaslist = ROOT.gROOT.GetListOfCanvases()
            if canvaslist:
                for canvas in canvaslist:
                    if canvas.IsDrawn():
                        self.drawer = JSROOT.CanvasDrawer(canvas)
                        if self.drawer._canJsDisplay():
                            self.Display(HTML(self.drawer.JsCode()))
                        else:
                            self.Display(self.drawer.PngImage())
                        canvas.ResetDrawn()
        
            
        except KeyboardInterrupt:
            self.interpreter.gROOT.SetInterrupt()
            status = 'interrupted'
            self.ioHandler.EndCapture()
            std_out = self.ioHandler.getStdout()
            std_err = self.ioHandler.getStderr()
        if not silent:
            ## Send output on stdout
            stream_content_stdout = {'name': 'stdout', 'text': std_out}
            self.send_response(self.iopub_socket, 'stream', stream_content_stdout)
            if std_err != "":
                stream_content_stderr = {'name': 'stderr', 'text': std_err}
                self.send_response(self.iopub_socket, 'stream', stream_content_stderr)
            
        reply = {'status': status,
                'execution_count': self.execution_count,
                'payload': [],
                'user_expressions': {},
                }

        if status == 'interrupted':
            pass
        elif status == 'error':
            err = {
                'ename': 'ename',
                'evalue': 'evalue',
                'traceback': traceback,
            }
            self.send_response(self.iopub_socket, 'error', err)
            reply.update(err)
        elif status == 'ok':
            pass
        else:
            raise ValueError("Invalid status: %r" % status)