Esempio n. 1
0
        private void EnvironmentReplWorkingDirectoryTest(
            PythonVisualStudioApp app,
            EnvDTE.Project project,
            TreeNode env
        ) {
            var path1 = Path.Combine(Path.GetDirectoryName(project.FullName), Guid.NewGuid().ToString("N"));
            var path2 = Path.Combine(Path.GetDirectoryName(project.FullName), Guid.NewGuid().ToString("N"));
            Directory.CreateDirectory(path1);
            Directory.CreateDirectory(path2);

            app.OpenSolutionExplorer().SelectProject(project);
            app.Dte.ExecuteCommand("Python.Interactive");

            using (var window = app.GetInteractiveWindow(string.Format("{0} Interactive", project.Name))) {
                Assert.IsNotNull(window, string.Format("Failed to find '{0} Interactive'", project.Name));
                app.ServiceProvider.GetUIThread().Invoke(() => project.GetPythonProject().SetProjectProperty("WorkingDirectory", path1));

                window.Reset();
                window.ExecuteText("import os; os.getcwd()").Wait();
                window.WaitForTextEnd(
                    string.Format("'{0}'", path1.Replace("\\", "\\\\")),
                    ">"
                );

                app.ServiceProvider.GetUIThread().Invoke(() => project.GetPythonProject().SetProjectProperty("WorkingDirectory", path2));

                window.Reset();
                window.ExecuteText("import os; os.getcwd()").Wait();
                window.WaitForTextEnd(
                    string.Format("'{0}'", path2.Replace("\\", "\\\\")),
                    ">"
                );
            }
        }
        private static void ProfileProject(SessionNode session, EnvDTE.Project projectToProfile, bool openReport)
        {
            var project = projectToProfile.GetPythonProject();

            var config = project?.GetLaunchConfigurationOrThrow();

            if (config == null)
            {
                MessageBox.Show(Strings.ProjectInterpreterNotFound.FormatUI(projectToProfile.Name), Strings.ProductTitle);
                return;
            }

            if (string.IsNullOrEmpty(config.ScriptName))
            {
                MessageBox.Show(Strings.NoProjectStartupFile, Strings.ProductTitle);
                return;
            }

            if (string.IsNullOrEmpty(config.WorkingDirectory) || config.WorkingDirectory == ".")
            {
                config.WorkingDirectory = project.ProjectHome;
                if (string.IsNullOrEmpty(config.WorkingDirectory))
                {
                    config.WorkingDirectory = Path.GetDirectoryName(config.ScriptName);
                }
            }

            RunProfiler(session, config, openReport);
        }
Esempio n. 3
0
        internal void OpenProject(VisualStudioApp app, string slnName, PythonVersion python, out PythonProjectNode projectNode, out EnvDTE.Project dteProject)
        {
            dteProject = app.OpenProject(app.CopyProjectForTest("TestData\\Targets\\" + slnName));
            var pn   = projectNode = dteProject.GetPythonProject();
            var fact = projectNode.InterpreterFactories.Where(x => x.Configuration.Id == python.Id).FirstOrDefault();

            Assert.IsNotNull(fact, "Project does not contain expected interpreter");
            app.ServiceProvider.GetUIThread().Invoke(() => pn.ActiveInterpreter = fact);
            dteProject.Save();
        }
Esempio n. 4
0
        internal void OpenProject(VisualStudioApp app, string slnName, out PythonProjectNode projectNode, out EnvDTE.Project dteProject)
        {
            PythonVersion.AssertInstalled();

            dteProject  = app.OpenProject("TestData\\Targets\\" + slnName);
            projectNode = dteProject.GetPythonProject();
            var fact = projectNode.InterpreterFactories.Where(x => x.Configuration.Id == PythonVersion.Id).FirstOrDefault();

            Assert.IsNotNull(fact, "Project does not contain expected interpreter");
            projectNode.ActiveInterpreter = fact;
            dteProject.Save();
        }