示例#1
0
        public LaunchConfiguration GetLaunchConfigurationOrThrow()
        {
            if (IsWorkspace)
            {
                if (!_pythonWorkspace.CurrentFactory.Configuration.IsAvailable())
                {
                    throw new Exception("MissingEnvironment");
                }

                var config = new LaunchConfiguration(_pythonWorkspace.CurrentFactory.Configuration)
                {
                    WorkingDirectory = _pythonWorkspace.Location,
                    SearchPaths      = _pythonWorkspace.GetAbsoluteSearchPaths().ToList(),
                    Environment      = PathUtils.ParseEnvironment(_pythonWorkspace.GetStringProperty(PythonConstants.EnvironmentSetting) ?? "")
                };

                return(config);
            }

            return(_pythonProject.GetLaunchConfigurationOrThrow());
        }
        private static TestFrameworkType GetTestFramework(IPythonWorkspaceContext workspace)
        {
            var testFrameworkType = TestFrameworkType.None;

            try {
                string testFrameworkStr = workspace.GetStringProperty(PythonConstants.TestFrameworkSetting);
                if (Enum.TryParse <TestFrameworkType>(testFrameworkStr, ignoreCase: true, out TestFrameworkType parsedFramework))
                {
                    testFrameworkType = parsedFramework;
                }
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                Trace.WriteLine("Exception : " + ex.Message);
            }

            return(testFrameworkType);
        }
示例#3
0
        public static string GetStringSetting(
            string settingName,
            string filePath,
            IServiceProvider site,
            IPythonWorkspaceContext workspace,
            out ValueSource source)
        {
            source = ValueSource.Global;
            string value = null;

            if (workspace != null)
            {
                // Try workspace file
                value = workspace.GetStringProperty(settingName);
                if (value != null)
                {
                    source = ValueSource.Workspace;
                }
            }
            else
            {
                // Try project
                if (filePath != null)
                {
                    var project = site.GetProjectContainingFile(filePath);
                    if (project != null)
                    {
                        value = project.GetProjectProperty(settingName);
                        if (value != null)
                        {
                            source = ValueSource.Project;
                        }
                    }
                }
            }

            return(value);
        }