Exemplo n.º 1
0
        private void DeleteEnvironment_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            // TODO: this is assuming that all environments that CanBeDeleted are conda environments, which may not be true in the future
            var view   = e.Parameter as EnvironmentView;
            var result = MessageBox.Show(
                EnvironmentsList.Resources.EnvironmentPathsExtensionDeleteConfirmation.FormatUI(view.Configuration.GetPrefixPath()),
                EnvironmentsList.Resources.ProductTitle,
                MessageBoxButton.YesNo,
                MessageBoxImage.Question
                );

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            var compModel = _site.GetService(typeof(SComponentModel)) as IComponentModel;
            var registry  = compModel.GetService <IInterpreterRegistryService>();
            var mgr       = CondaEnvironmentManager.Create(_site);

            mgr.DeleteAsync(
                view.Configuration.GetPrefixPath(),
                new CondaEnvironmentManagerUI(_outputWindow),
                CancellationToken.None
                ).HandleAllExceptions(_site, GetType()).DoNotWait();
        }
        private static CondaEnvironmentManager CreateEnvironmentManager()
        {
            if (!PythonPaths.AnacondaVersions.Any())
            {
                Assert.Inconclusive("Anaconda is required.");
            }

            var    version   = PythonPaths.AnacondaVersions.FirstOrDefault();
            string condaPath = CondaUtils.GetCondaExecutablePath(version.PrefixPath, allowBatch: false);

            Assert.IsTrue(File.Exists(condaPath), $"Conda executable not found: '{condaPath}' for environment prefix at '{version.PrefixPath}'");
            return(CondaEnvironmentManager.Create(condaPath));
        }
Exemplo n.º 3
0
        private static CondaEnvironmentManager CreateEnvironmentManager()
        {
            if (!PythonPaths.AnacondaVersions.Any())
            {
                Assert.Inconclusive("Anaconda is required.");
            }

            var container    = CreateCompositionContainer();
            var interpreters = container.GetExportedValue <IInterpreterRegistryService>();
            var mgr          = CondaEnvironmentManager.Create(interpreters);

            Assert.IsNotNull(mgr, "Could not create conda environment manager.");
            return(mgr);
        }
        public AddCondaEnvironmentView(
            IServiceProvider serviceProvider,
            ProjectView[] projects,
            ProjectView selectedProject
            ) : base(serviceProvider, projects, selectedProject)
        {
            _condaMgr           = CondaEnvironmentManager.Create(Site);
            _updatePreviewTimer = new Timer(UpdatePreviewTimerCallback);

            IsCondaMissing  = _condaMgr == null;
            PageName        = Strings.AddCondaEnvironmentTabHeader;
            AcceptCaption   = Strings.AddEnvironmentCreateButton;
            IsAcceptEnabled = !IsCondaMissing;

            SetAsCurrent            = SelectedProject != null;
            SetAsDefault            = false;
            ViewInEnvironmentWindow = false;

            ResetProjectDependentProperties();
        }
Exemplo n.º 5
0
        internal async Task CreateEnvironmentAsync(CondaEnvironmentView view)
        {
            var mgr = CondaEnvironmentManager.Create(_registry);

            if (mgr == null)
            {
                // TODO: Instead of this message box, hide the input/create
                // controls and show a message there instead.
                MessageBox.Show(Resources.CondaExtensionNotAvailable, Resources.ProductTitle);
                return;
            }

            _isWorking = true;
            try {
                // Use single equal sign to install the selected version or any of its revisions
                var packages = new[] { PackageSpec.FromArguments($"python={view.VersionName}") };
                await mgr.CreateAsync(view.EnvironmentName, packages, this, CancellationToken.None);
            } finally {
                _isWorking = false;
            }
        }