Exemplo n.º 1
0
        public TreeNode AddExistingEnvironment(EnvDTE.Project project, string envPath, out string envName)
        {
            var environmentsNode = OpenSolutionExplorer().FindChildOfProject(project, Strings.Environments);

            environmentsNode.Select();

            var factory = InterpreterService.Interpreters.FirstOrDefault(interp => PathUtils.IsSameDirectory(interp.Configuration.PrefixPath, envPath));

            envName = string.Format("Python {1} ({2})", PathUtils.GetFileOrDirectoryName(envPath), factory.Configuration.Version, factory.Configuration.Architecture);

            var dlg = AddExistingEnvironmentDialogWrapper.FromDte(this);

            try {
                dlg.Interpreter = envName;

                Console.WriteLine("Expecting environment named: {0}", envName);

                dlg.ClickAdd();
            } catch (Exception) {
                dlg.CloseWindow();
                throw;
            }

            return(OpenSolutionExplorer().WaitForChildOfProject(project, Strings.Environments, envName));
        }
Exemplo n.º 2
0
        private void ApplyAddLocalCustomEnvironmentDialog(string envPath, string descriptionOverride, string expectedLangVer, string expectedArch, out string envDescription, out string envPrefixPath, out string languageVer, out string architecture)
        {
            envDescription = string.Empty;
            envPrefixPath  = string.Empty;
            languageVer    = string.Empty;

            var dlg = AddExistingEnvironmentDialogWrapper.FromDte(this);

            try {
                dlg.SelectCustomInterpreter();
                dlg.PrefixPath = envPath;

                // Need to wait for async auto detect to be finished
                dlg.WaitForReady();

                if (expectedLangVer != null)
                {
                    Assert.AreEqual(expectedLangVer, dlg.LanguageVersion);
                }

                if (expectedArch != null)
                {
                    Assert.AreEqual(expectedArch, dlg.Architecture);
                }

                dlg.RegisterGlobally = false;

                if (descriptionOverride != null)
                {
                    dlg.Description = descriptionOverride;
                }

                envDescription = dlg.Description;
                envPrefixPath  = dlg.PrefixPath;
                languageVer    = dlg.LanguageVersion;
                architecture   = dlg.Architecture;

                Console.WriteLine("Adding custom env");
                Console.WriteLine("  Description: {0}", envDescription);
                Console.WriteLine("  Prefix: {0}", envPrefixPath);
                Console.WriteLine("  Version: {0}", languageVer);
                Console.WriteLine("  Architecture: {0}", architecture);

                dlg.ClickAdd();
            } catch (Exception) {
                dlg.CloseWindow();
                throw;
            }
        }
Exemplo n.º 3
0
        public TreeNode AddLocalCustomEnvironment(EnvDTE.Project project, string envPath, string descriptionOverride, string expectedLangVer, string expectedArch, out string envName)
        {
            var environmentsNode = OpenSolutionExplorer().FindChildOfProject(project, Strings.Environments);

            environmentsNode.Select();

            var dlg = AddExistingEnvironmentDialogWrapper.FromDte(this);

            try {
                dlg.SelectCustomInterpreter();
                dlg.PrefixPath = envPath;

                // Need to wait for async auto detect to be finished
                dlg.WaitForReady();

                if (expectedLangVer != null)
                {
                    Assert.AreEqual(expectedLangVer, dlg.LanguageVersion);
                }

                if (expectedArch != null)
                {
                    Assert.AreEqual(expectedArch, dlg.Architecture);
                }

                dlg.RegisterGlobally = false;

                if (descriptionOverride != null)
                {
                    dlg.Description = descriptionOverride;
                }

                envName = dlg.Description;
                Console.WriteLine("Expecting environment named: {0}", envName);

                dlg.ClickAdd();
            } catch (Exception) {
                dlg.CloseWindow();
                throw;
            }

            return(OpenSolutionExplorer().WaitForChildOfProject(project, Strings.Environments, envName));
        }
Exemplo n.º 4
0
        private void ApplyAddExistingEnvironmentDialog(string envPath, out string envName)
        {
            var factory = InterpreterService.Interpreters.FirstOrDefault(interp => PathUtils.IsSameDirectory(interp.Configuration.GetPrefixPath(), envPath));

            envName = string.Format("Python {1} ({2})", PathUtils.GetFileOrDirectoryName(envPath), factory.Configuration.Version, factory.Configuration.Architecture);

            var dlg = AddExistingEnvironmentDialogWrapper.FromDte(this);

            try {
                dlg.Interpreter = envName;

                Console.WriteLine("Adding existing env");
                Console.WriteLine("  Name: {0}", envName);
                Console.WriteLine("  Prefix: {0}", envPath);

                dlg.ClickAdd();
            } catch (Exception) {
                dlg.CloseWindow();
                throw;
            }
        }