Exemplo n.º 1
0
    def RunDebuggee(self):
        """Run rpdb2args"""
        flag, localpythonpath = ToolConfig.GetPythonExecutablePath("PyDbg")
        # TODO: convert errors to error codes and translate to meaningful
        #       messages on main thread.
        if not flag:
            # No configured Python
            return [
                (u"No Python", localpythonpath, u"NA"),
            ]

        # No rpdb2 found in plugin
        if not pkg_resources.resource_exists("rpdb2", "rpdb2.py"):
            return ["No rpdb2 found"]

        rpdb2_script = pkg_resources.resource_filename("rpdb2", "rpdb2.py")

        if wx.Platform == "__WXMSW__":
            self.rpdb2args += ["--pwd=%s" % RpdbDebugger.password]
        else:
            rpdb2_pw = GetPwdFile(RpdbDebugger.password)
            self.rpdb2args += ["--rid=%s" % rpdb2_pw]

        childPath, parentPath = PyStudioUtils.get_packageroot(self.filename)

        # Start rpdb2
        cmdargs = ""
        debuggee = childPath
        if self.debuggerargs:
            cmdargs = self.debuggerargs.split(" ")
            for i, cmd in enumerate(cmdargs):
                if cmd == "%SCRIPT%":
                    cmdargs[i] = debuggee
                elif cmd == "%MODULE%":
                    debuggee = PyStudioUtils.get_modulepath(childPath)
                    cmdargs[i] = debuggee

            cmdargs = self.rpdb2args + cmdargs
        else:
            cmdargs = self.rpdb2args + [
                debuggee,
            ]
        allargs = cmdargs
        if self.programargs:
            allargs = allargs + self.programargs.split(" ")
        rpdb2_cmd = [localpythonpath, "-u", rpdb2_script] + allargs
        text = ""
        if self.pythonpath:
            text += "Using PYTHONPATH + %s\n" % u", ".join(self.pythonpath)
        text += "Rpdb2 command line: %s" % " ".join(rpdb2_cmd)
        text += "\nDirectory Variables file: %s\n\n" % self.dirvarfile
        self.debuggeewindow.SetText(_(text))
        self.debuggeewindow.calldebugger = self.RunDebugger
        RpdbDebugger().do_abort()
        RpdbDebugger().debuggerattachedtext = self.debuggerattachedtext
        RpdbDebugger().debuggerdetachedtext = self.debuggerdetachedtext
        RpdbDebugger().remoteprocess = False
        self.processcreator = AsyncProcessCreator(self.debuggeewindow,
                                                  self.UpdateOutput, "PyDbg",
                                                  parentPath, rpdb2_cmd,
                                                  self.pythonpath)
        self.processcreator.start()
        util.Log("[PyDbg][info] Rpdb2 command running")