Пример #1
0
    def doIt(self, dbg):
        """ Converts request into completions """
        try:
            remove_path = None
            try:

                frame = pydevd_vars.findFrame(self.thread_id, self.frame_id)
                if frame is not None:

                    msg = _pydev_completer.GenerateCompletionsAsXML(
                        frame, self.act_tok)

                    cmd = dbg.cmdFactory.makeGetCompletionsMessage(
                        self.sequence, msg)
                    dbg.writer.addCommand(cmd)
                else:
                    cmd = dbg.cmdFactory.makeErrorMessage(
                        self.sequence,
                        "InternalGetCompletions: Frame not found: %s from thread: %s"
                        % (self.frame_id, self.thread_id))
                    dbg.writer.addCommand(cmd)

            finally:
                if remove_path is not None:
                    sys.path.remove(remove_path)

        except:
            exc = GetExceptionTracebackStr()
            sys.stderr.write('%s\n' % (exc, ))
            cmd = dbg.cmdFactory.makeErrorMessage(
                self.sequence, "Error evaluating expression " + exc)
            dbg.writer.addCommand(cmd)
Пример #2
0
 def doIt(self, dbg):
     """ Create an XML for console output, error and more (true/false)
     <xml>
         <output message=output_message></output>
         <error message=error_message></error>
         <more>true/false</more>
     </xml>
     """
     try:
         frame = pydevd_vars.findFrame(self.thread_id, self.frame_id)
         if frame is not None:
             console_message = pydevd_console.execute_console_command(
                 frame, self.thread_id, self.frame_id, self.line)
             cmd = dbg.cmdFactory.makeSendConsoleMessage(
                 self.sequence, console_message.toXML())
         else:
             console_message.add_console_message(
                 pydevd_console.CONSOLE_ERROR,
                 "Select the valid frame in the debug view")
             cmd = dbg.cmdFactory.makeErrorMessage(self.sequence,
                                                   console_message.toXML())
     except:
         exc = GetExceptionTracebackStr()
         cmd = dbg.cmdFactory.makeErrorMessage(
             self.sequence, "Error evaluating expression " + exc)
     dbg.writer.addCommand(cmd)
Пример #3
0
    def doIt( self, dbg ):
        """ Converts request into completions """
        try:
            remove_path = None
            try:

                frame = pydevd_vars.findFrame( self.thread_id, self.frame_id )
                if frame is not None:

                    msg = _pydev_completer.GenerateCompletionsAsXML( frame, self.act_tok )

                    cmd = dbg.cmdFactory.makeGetCompletionsMessage( self.sequence, msg )
                    dbg.writer.addCommand( cmd )
                else:
                    cmd = dbg.cmdFactory.makeErrorMessage( self.sequence, "InternalGetCompletions: Frame not found: %s from thread: %s" % ( self.frame_id, self.thread_id ) )
                    dbg.writer.addCommand( cmd )


            finally:
                if remove_path is not None:
                    sys.path.remove( remove_path )

        except:
            exc = GetExceptionTracebackStr()
            sys.stderr.write( '%s\n' % ( exc, ) )
            cmd = dbg.cmdFactory.makeErrorMessage( self.sequence, "Error evaluating expression " + exc )
            dbg.writer.addCommand( cmd )
    def doIt(self, dbg):
        """ Converts request into completions """
        try:
            remove_path = None
            try:
                import _completer
            except:
                path = os.environ['PYDEV_COMPLETER_PYTHONPATH']
                sys.path.append(path)
                remove_path = path
                import _completer

            try:

                frame = pydevd_vars.findFrame(self.thread_id, self.frame_id)

                #Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329
                #(Names not resolved in generator expression in method)
                #See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html
                updated_globals = dict()
                updated_globals.update(frame.f_globals)
                updated_globals.update(
                    frame.f_locals
                )  #locals later because it has precedence over the actual globals

                completer = _completer.Completer(updated_globals, None)
                #list(tuple(name, descr, parameters, type))
                completions = completer.complete(self.act_tok)

                def makeValid(s):
                    return pydevd_vars.makeValidXmlValue(
                        pydevd_vars.quote(s, '/>_= \t'))

                msg = "<xml>"

                for comp in completions:
                    msg += '<comp p0="%s" p1="%s" p2="%s" p3="%s"/>' % (
                        makeValid(comp[0]),
                        makeValid(comp[1]),
                        makeValid(comp[2]),
                        makeValid(comp[3]),
                    )
                msg += "</xml>"

                cmd = dbg.cmdFactory.makeGetCompletionsMessage(
                    self.sequence, msg)
                dbg.writer.addCommand(cmd)

            finally:
                if remove_path is not None:
                    sys.path.remove(remove_path)

        except:
            exc = GetExceptionTracebackStr()
            sys.stderr.write('%s\n' % (exc, ))
            cmd = dbg.cmdFactory.makeErrorMessage(
                self.sequence, "Error evaluating expression " + exc)
            dbg.writer.addCommand(cmd)
Пример #5
0
    def doIt(self, dbg):
        """ Converts request into completions """
        try:
            remove_path = None
            try:
                import _completer
            except:
                path = os.environ['PYDEV_COMPLETER_PYTHONPATH']
                sys.path.append(path)
                remove_path = path
                import _completer
            
            try:
                
                frame = pydevd_vars.findFrame(self.thread_id, self.frame_id)
                if frame is not None:
                
                    #Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329
                    #(Names not resolved in generator expression in method)
                    #See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html
                    updated_globals = {}
                    updated_globals.update(frame.f_globals)
                    updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals
                
                    completer = _completer.Completer(updated_globals, None)
                    #list(tuple(name, descr, parameters, type))
                    completions = completer.complete(self.act_tok)
                    
                    
                    def makeValid(s):
                        return pydevd_vars.makeValidXmlValue(pydevd_vars.quote(s, '/>_= \t'))
                    
                    msg = "<xml>"
                    
                    for comp in completions:
                        msg += '<comp p0="%s" p1="%s" p2="%s" p3="%s"/>' % (makeValid(comp[0]), makeValid(comp[1]), makeValid(comp[2]), makeValid(comp[3]),)
                    msg += "</xml>"
                    
                    cmd = dbg.cmdFactory.makeGetCompletionsMessage(self.sequence, msg)
                    dbg.writer.addCommand(cmd)
                else:
                    cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "InternalGetCompletions: Frame not found: %s from thread: %s" % (self.frame_id, self.thread_id))
                    dbg.writer.addCommand(cmd)

                
            finally:
                if remove_path is not None:
                    sys.path.remove(remove_path)
                    
        except:
            exc = GetExceptionTracebackStr()
            sys.stderr.write('%s\n' % (exc,))
            cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "Error evaluating expression " + exc)
            dbg.writer.addCommand(cmd)
Пример #6
0
 def doIt( self, dbg ):
     """ Get completions and write back to the client
     """
     try:
         frame = pydevd_vars.findFrame( self.thread_id, self.frame_id )
         completions_xml = pydevd_console.get_completions( frame, self.act_tok )
         cmd = dbg.cmdFactory.makeSendConsoleMessage( self.sequence, completions_xml )
         dbg.writer.addCommand( cmd )
     except:
         exc = GetExceptionTracebackStr()
         cmd = dbg.cmdFactory.makeErrorMessage( self.sequence, "Error in fetching completions" + exc )
         dbg.writer.addCommand( cmd )
Пример #7
0
def consoleExec(thread_id, frame_id, expression):
    """returns 'False' in case expression is partially correct
    """
    frame = pydevd_vars.findFrame(thread_id, frame_id)

    expression = str(expression.replace('@LINE@', '\n'))

    #Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329
    #(Names not resolved in generator expression in method)
    #See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html
    updated_globals = {}
    updated_globals.update(frame.f_globals)
    updated_globals.update(
        frame.f_locals
    )  #locals later because it has precedence over the actual globals

    if IPYTHON:
        return exec_code(CodeFragment(expression), updated_globals,
                         frame.f_locals)

    interpreter = ConsoleWriter()

    try:
        code = compile_command(expression)
    except (OverflowError, SyntaxError, ValueError):
        # Case 1
        interpreter.showsyntaxerror()
        return False

    if code is None:
        # Case 2
        return True

    #Case 3

    try:
        Exec(code, updated_globals, frame.f_locals)

    except SystemExit:
        raise
    except:
        interpreter.showtraceback()

    return False
 def doIt(self, dbg):
     """ Converts request into python variable """
     try:
         try:
             xml = "<xml>"            
             frame = pydevd_vars.findFrame(self.thread_id, self.frame_id)
             xml += pydevd_vars.frameVarsToXML(frame)
             del frame
             xml += "</xml>"
             cmd = dbg.cmdFactory.makeGetFrameMessage(self.sequence, xml)
             dbg.writer.addCommand(cmd)
         except pydevd_vars.FrameNotFoundError:
             #pydevd_vars.dumpFrames(self.thread_id)
             #don't print this error: frame not found: means that the client is not synchronized (but that's ok)
             cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "Frame not found: %s from thread: %s" % (self.frame_id, self.thread_id))
             dbg.writer.addCommand(cmd)
     except:
         cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "Error resolving frame: %s from thread: %s" % (self.frame_id, self.thread_id))
         dbg.writer.addCommand(cmd)
Пример #9
0
 def doIt(self, dbg):
     """ Converts request into python variable """
     try:
         frame = pydevd_vars.findFrame(self.thread_id, self.frame_id)
         if frame is not None:
             xml = "<xml>"
             xml += pydevd_vars.frameVarsToXML(frame.f_locals)
             del frame
             xml += "</xml>"
             cmd = dbg.cmdFactory.makeGetFrameMessage(self.sequence, xml)
             dbg.writer.addCommand(cmd)
         else:
             #pydevd_vars.dumpFrames(self.thread_id)
             #don't print this error: frame not found: means that the client is not synchronized (but that's ok)
             cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "Frame not found: %s from thread: %s" % (self.frame_id, self.thread_id))
             dbg.writer.addCommand(cmd)
     except:
         cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "Error resolving frame: %s from thread: %s" % (self.frame_id, self.thread_id))
         dbg.writer.addCommand(cmd)
Пример #10
0
 def doIt( self, dbg ):
     """ Create an XML for console output, error and more (true/false)
     <xml>
         <output message=output_message></output>
         <error message=error_message></error>
         <more>true/false</more>
     </xml>
     """
     try:
         frame = pydevd_vars.findFrame( self.thread_id, self.frame_id )
         if frame is not None:
             console_message = pydevd_console.execute_console_command( frame, self.thread_id, self.frame_id, self.line )
             cmd = dbg.cmdFactory.makeSendConsoleMessage( self.sequence, console_message.toXML() )
         else:
             console_message.add_console_message( pydevd_console.CONSOLE_ERROR, "Select the valid frame in the debug view" )
             cmd = dbg.cmdFactory.makeErrorMessage( self.sequence, console_message.toXML() )
     except:
         exc = GetExceptionTracebackStr()
         cmd = dbg.cmdFactory.makeErrorMessage( self.sequence, "Error evaluating expression " + exc )
     dbg.writer.addCommand( cmd )
Пример #11
0
def consoleExec(thread_id, frame_id, expression):
    """returns 'False' in case expression is partialy correct
    """
    frame = pydevd_vars.findFrame(thread_id, frame_id)

    expression = str(expression.replace('@LINE@', '\n'))

    #Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329
    #(Names not resolved in generator expression in method)
    #See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html
    updated_globals = {}
    updated_globals.update(frame.f_globals)
    updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals

    if IPYTHON:
        return exec_expression(expression, updated_globals, frame.f_locals)

    interpreter = ConsoleWriter()

    try:
        code = compile_command(expression)
    except (OverflowError, SyntaxError, ValueError):
        # Case 1
        interpreter.showsyntaxerror()
        return False

    if code is None:
        # Case 2
        return True

    #Case 3

    try:
        Exec(code, updated_globals, frame.f_locals)

    except SystemExit:
        raise
    except:
        interpreter.showtraceback()

    return False