private InterpretersNode(PythonProjectNode project, string id) : base(project, MakeElement(project)) { _absentId = id; _canRemove = true; _captionSuffix = Strings.MissingSuffix; }
public static InterpretersNode CreateAbsentInterpreterNode(PythonProjectNode project, string id) { return(new InterpretersNode(project, id)); }
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( SR.GetString(SR.CustomCommandPrerequisitesInstallMissing), SR.GetString(SR.CustomCommandPrerequisitesInstallMissingSubtext) + "\r\n\r\n" + string.Join("\r\n", packagesToInstall)); var runAnywayButton = new TaskDialogButton(SR.GetString(SR.CustomCommandPrerequisitesRunAnyway)); var doNotRunButton = new TaskDialogButton(SR.GetString(SR.CustomCommandPrerequisitesDoNotRun)); var taskDialog = new TaskDialog(project.Site) { Title = SR.ProductName, MainInstruction = SR.GetString(SR.CustomCommandPrerequisitesInstruction), Content = SR.GetString(SR.CustomCommandPrerequisitesContent, 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); } }
private static ProjectElement MakeElement(PythonProjectNode project) { return(new VirtualProjectElement(project)); }
public PythonAssemblyReferenceNode(PythonProjectNode root, ProjectElement element) : base(root, element) { }
public PythonAssemblyReferenceNode(PythonProjectNode root, string assemblyPath) : base(root, assemblyPath) { }
public TestFrameworkProjectInfoBar(IServiceProvider site, PythonProjectNode projectNode) : base(site) { Project = projectNode ?? throw new ArgumentNullException(nameof(projectNode)); }
public InterpretersContainerNode(PythonProjectNode project) : base(project.ProjectMgr) { _projectNode = project; ExcludeNodeFromScc = true; }
public override async Task CheckAsync() { if (IsCreated) { return; } if (!Project.Site.GetPythonToolsService().GeneralOptions.PromptForPackageInstallation) { return; } var suppressProp = Project.GetProjectProperty(PythonConstants.SuppressPackageInstallationPrompt); if (suppressProp.IsTrue()) { return; } if (Project.IsActiveInterpreterGlobalDefault) { return; } var txtPath = Project.GetRequirementsTxtPath(); if (!File.Exists(txtPath)) { return; } var active = Project.ActiveInterpreter; if (!active.IsRunnable()) { return; } var pm = Project.InterpreterOptions.GetPackageManagers(active).FirstOrDefault(p => p.UniqueKey == "pip"); if (pm == null) { return; } var missing = await PackagesMissingAsync(pm, txtPath); if (!missing) { return; } Action installPackages = () => { Logger?.LogEvent( PythonLogEvent.PackageInstallInfoBar, new PackageInstallInfoBarInfo() { Action = PackageInstallInfoBarActions.Install, } ); PythonProjectNode.InstallRequirementsAsync(Project.Site, pm, txtPath) .HandleAllExceptions(Project.Site, typeof(PackageInstallInfoBar)) .DoNotWait(); Close(); }; Action projectIgnore = () => { Logger?.LogEvent( PythonLogEvent.PackageInstallInfoBar, new PackageInstallInfoBarInfo() { Action = PackageInstallInfoBarActions.Ignore, } ); Project.SetProjectProperty(PythonConstants.SuppressEnvironmentCreationPrompt, true.ToString()); Close(); }; var messages = new List <IVsInfoBarTextSpan>(); var actions = new List <InfoBarActionItem>(); messages.Add(new InfoBarTextSpan( Strings.RequirementsTxtInstallPackagesInfoBarMessage.FormatUI( PathUtils.GetFileOrDirectoryName(txtPath), Project.Caption, pm.Factory.Configuration.Description ))); actions.Add(new InfoBarButton(Strings.RequirementsTxtInfoBarInstallPackagesAction, installPackages)); actions.Add(new InfoBarButton(Strings.RequirementsTxtInfoBarProjectIgnoreAction, projectIgnore)); Logger?.LogEvent( PythonLogEvent.PackageInstallInfoBar, new PackageInstallInfoBarInfo() { Action = PackageInstallInfoBarActions.Prompt, } ); Create(new InfoBarModel(messages, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true)); }
public PythonReferenceContainerNode(PythonProjectNode root) : base(root) { }
public PackageInstallInfoBar(PythonProjectNode projectNode) : base(projectNode) { }
internal PythonProjectNodeProperties(PythonProjectNode node) : base(node) { }
public CommonSearchPathContainerNode(PythonProjectNode project) : base(project.ProjectMgr) { _projectNode = project; this.ExcludeNodeFromScc = true; }
public CommonSearchPathNode(PythonProjectNode project, string path, int index) : base(project, path, new VirtualProjectElement(project)) { _index = index; }
public CurrentWorkingDirectoryNode(PythonProjectNode project, string path) : base(project, path, new VirtualProjectElement(project)) { }
public PythonProjectConfig(PythonProjectNode project, string configuration) : base(project, configuration) { _project = project; }
public PackageInstallProjectInfoBar(IServiceProvider site, PythonProjectNode projectNode) : base(site) { Project = projectNode ?? throw new ArgumentNullException(nameof(projectNode)); }