本文整理汇总了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;
}
示例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);
}
}