当前位置: 首页>>代码示例>>C#>>正文


C# PythonProjectNode.GetInterpreterFactoryOrThrow方法代码示例

本文整理汇总了C#中PythonProjectNode.GetInterpreterFactoryOrThrow方法的典型用法代码示例。如果您正苦于以下问题:C# PythonProjectNode.GetInterpreterFactoryOrThrow方法的具体用法?C# PythonProjectNode.GetInterpreterFactoryOrThrow怎么用?C# PythonProjectNode.GetInterpreterFactoryOrThrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PythonProjectNode的用法示例。


在下文中一共展示了PythonProjectNode.GetInterpreterFactoryOrThrow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInterpreterPath

        internal static string GetInterpreterPath(PythonProjectNode project, bool isWindows) {
            var factory = project.GetInterpreterFactoryOrThrow();

            return isWindows ?
                factory.Configuration.WindowsInterpreterPath :
                factory.Configuration.InterpreterPath;
        }
开发者ID:smallwave,项目名称:PTVS,代码行数:7,代码来源:CustomCommand.cs

示例2: ExecuteWorker

        private async Task ExecuteWorker(PythonProjectNode project) {
            _errorListProvider.Tasks.Clear();

            var interpFactory = project.GetInterpreterFactoryOrThrow();
            var startInfo = GetStartInfo(project);

            var packagesToInstall = new List<string>();
            foreach (var pkg in startInfo.RequiredPackages) {
                if (!await Pip.IsInstalled(interpFactory, pkg)) {
                    packagesToInstall.Add(pkg);
                }
            }

            if (packagesToInstall.Any()) {
                var installMissingButton = new TaskDialogButton(
                    Strings.CustomCommandPrerequisitesInstallMissing,
                    Strings.CustomCommandPrerequisitesInstallMissingSubtext + "\r\n\r\n" + string.Join("\r\n", packagesToInstall));
                var runAnywayButton = new TaskDialogButton(Strings.CustomCommandPrerequisitesRunAnyway);
                var doNotRunButton = new TaskDialogButton(Strings.CustomCommandPrerequisitesDoNotRun);

                var taskDialog = new TaskDialog(project.Site) {
                    Title = Strings.ProductTitle,
                    MainInstruction = Strings.CustomCommandPrerequisitesInstruction,
                    Content = Strings.CustomCommandPrerequisitesContent.FormatUI(DisplayLabelWithoutAccessKeys),
                    AllowCancellation = true,
                    Buttons = { installMissingButton, runAnywayButton, doNotRunButton, TaskDialogButton.Cancel }
                };

                var selectedButton = taskDialog.ShowModal();
                if (selectedButton == installMissingButton) {
                    await Pip.Install(
                        project.Site,
                        interpFactory,
                        string.Join(" ", packagesToInstall),
                        false,
                        OutputWindowRedirector.GetGeneral(project.Site));
                } else if (selectedButton == runAnywayButton) {
                } else {
                    throw new TaskCanceledException();
                }
            }

            if (startInfo.TargetType == CreatePythonCommandItem.TargetTypePip) {
                if (startInfo.ExecuteInOutput) {
                    await Pip.Install(
                        _project.Site,
                        interpFactory,
                        string.IsNullOrEmpty(startInfo.Arguments) ?
                            startInfo.Filename :
                            string.Format("{0} {1}", startInfo.Filename, startInfo.Arguments),
                        project.Site,
                        false,
                        OutputWindowRedirector.GetGeneral(project.Site)
                    );
                    return;
                }

                // Rewrite start info to execute 
                startInfo.TargetType = CreatePythonCommandItem.TargetTypeModule;
                startInfo.AddArgumentAtStart(startInfo.Filename);
                startInfo.Filename = "pip";
            }

            if (startInfo.ExecuteInRepl) {
                if (await RunInRepl(project, startInfo)) {
                    return;
                }
            }

            startInfo.AdjustArgumentsForProcessStartInfo(GetInterpreterPath(project, false));

            if (startInfo.ExecuteInOutput) {
                RunInOutput(project, startInfo);
            } else {
                RunInConsole(project, startInfo);
            }
        }
开发者ID:smallwave,项目名称:PTVS,代码行数:77,代码来源:CustomCommand.cs


注:本文中的PythonProjectNode.GetInterpreterFactoryOrThrow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。