Example #1
0
        public override int DebugLaunch(uint flags)
        {
            if (_project.ShouldWarnOnLaunch)
            {
                var pyService = ProjectMgr.Site.GetPythonToolsService();
                if (pyService.DebuggerOptions.PromptBeforeRunningWithBuildError)
                {
                    var res = new StartWithErrorsDialog(pyService).ShowDialog();
                    if (res == DialogResult.No)
                    {
                        return(VSConstants.S_OK);
                    }
                }
            }

            try {
                return(base.DebugLaunch(flags));
            } catch (MissingInterpreterException ex) {
                if (_project.ActiveInterpreter == _project.InterpreterRegistry.NoInterpretersValue)
                {
                    PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                }
                else
                {
                    MessageBox.Show(ex.Message, Strings.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return(VSConstants.S_OK);
            } catch (NoInterpretersException ex) {
                PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                return(VSConstants.S_OK);
            }
        }
Example #2
0
        public override int DebugLaunch(uint flags) {
            if (_project.ShouldWarnOnLaunch) {
                var pyService = ProjectMgr.Site.GetPythonToolsService();
                if (pyService.DebuggerOptions.PromptBeforeRunningWithBuildError) {
                    var res = new StartWithErrorsDialog(pyService).ShowDialog();
                    if (res == DialogResult.No) {
                        return VSConstants.S_OK;
                    }
                }
            }

            try {
                return base.DebugLaunch(flags);
            } catch (MissingInterpreterException ex) {
                if (_project.ActiveInterpreter == _project.InterpreterRegistry.NoInterpretersValue) {
                    PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                } else {
                    MessageBox.Show(ex.Message, Strings.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return VSConstants.S_OK;
            } catch (NoInterpretersException ex) {
                PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                return VSConstants.S_OK;
            }
        }
Example #3
0
        public override int DebugLaunch(uint flags)
        {
            if (_project.ErrorFiles.Count > 0)
            {
                if (StartWithErrorsDialog.ShouldShow)
                {
                    var res = new StartWithErrorsDialog().ShowDialog();
                    if (res == DialogResult.No)
                    {
                        return(VSConstants.S_OK);
                    }
                }
            }

            var model = (IComponentModel)ProjectMgr.GetService(typeof(SComponentModel));

            var allFactories = model.GetAllPythonInterpreterFactories();

            if (allFactories.Length == 0)
            {
                MessageBox.Show("No Python interpreters are installed.\r\n\r\nPlease download a Python distribution or configure an interpreter manually in Tools->Options->Python Tools->Interpreters.", "No Python Interpreters Installed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(VSConstants.S_OK);
            }

            return(base.DebugLaunch(flags));
        }
Example #4
0
        public override int DebugLaunch(uint flags)
        {
            if (_project.ShouldWarnOnLaunch)
            {
                var pyService = ProjectMgr.Site.GetPythonToolsService();
                if (pyService.DebuggerOptions.PromptBeforeRunningWithBuildError)
                {
                    var res = new StartWithErrorsDialog(pyService).ShowDialog();
                    if (res == DialogResult.No)
                    {
                        return(VSConstants.S_OK);
                    }
                }
            }

            string errorMessage = null;

            try {
                return(base.DebugLaunch(flags));
            } catch (MissingInterpreterException ex) {
                if (_project.ActiveInterpreter == _project.InterpreterRegistry.NoInterpretersValue)
                {
                    PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                }
                else
                {
                    errorMessage = ex.Message;
                }
            } catch (NoInterpretersException ex) {
                PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
            } catch (IOException ex) {
                errorMessage = ex.Message;
            } catch (NoStartupFileException ex) {
                errorMessage = ex.Message;
            } catch (ArgumentException ex) {
                // Previously used to handle "No startup file" which now has its own exception.
                // Keeping it in case some launchers started relying on us catching this.
                errorMessage = ex.Message;
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                var td = new TaskDialog(ProjectMgr.Site)
                {
                    Title             = Strings.ProductTitle,
                    MainInstruction   = Strings.FailedToLaunchDebugger,
                    Content           = errorMessage,
                    AllowCancellation = true
                };
                td.Buttons.Add(TaskDialogButton.Close);
                td.ShowModal();
            }

            return(VSConstants.S_OK);
        }
Example #5
0
        public override int DebugLaunch(uint flags)
        {
            if (_project.ShouldWarnOnLaunch)
            {
                var pyService = ProjectMgr.Site.GetPythonToolsService();
                if (pyService.DebuggerOptions.PromptBeforeRunningWithBuildError)
                {
                    var res = new StartWithErrorsDialog(pyService).ShowDialog();
                    if (res == DialogResult.No)
                    {
                        return(VSConstants.S_OK);
                    }
                }
            }

            string errorMessage = null;

            try {
                return(base.DebugLaunch(flags));
            } catch (MissingInterpreterException ex) {
                if (_project.ActiveInterpreter == _project.InterpreterRegistry.NoInterpretersValue)
                {
                    PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                }
                else
                {
                    errorMessage = ex.Message;
                }
            } catch (NoInterpretersException ex) {
                PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
            } catch (ArgumentException ex) {
                errorMessage = ex.Message;
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                var td = new TaskDialog(ProjectMgr.Site)
                {
                    Title           = Strings.ProductTitle,
                    MainInstruction = Strings.FailedToLaunchDebugger,
                    Content         = errorMessage
                };
                td.Buttons.Add(TaskDialogButton.Close);
                td.ShowModal();
            }

            return(VSConstants.S_OK);
        }
        public override int DebugLaunch(uint flags)
        {
            if (_project.ShouldWarnOnLaunch)
            {
                var pyService = ProjectMgr.Site.GetPythonToolsService();
                if (pyService.DebuggerOptions.PromptBeforeRunningWithBuildError)
                {
                    var res = new StartWithErrorsDialog(pyService).ShowDialog();
                    if (res == DialogResult.No)
                    {
                        return(VSConstants.S_OK);
                    }
                }
            }

            try {
                return(base.DebugLaunch(flags));
            } catch (NoInterpretersException ex) {
                PythonToolsPackage.OpenNoInterpretersHelpPage(ProjectMgr.Site, ex.HelpPage);
                return(VSConstants.S_OK);
            }
        }