private IEnumerable<Interpreter> GetInterpreters() { if (_options.AutoDetect) { _logger.LogTrace(Resources.Trace_AutoDetectingR); var engines = new RInstallation().GetCompatibleEngines(); if (engines.Any()) { foreach (var e in engines) { var detected = new Interpreter(this, Guid.NewGuid().ToString(), e.Name, e.InstallPath, e.BinPath, e.Version); _logger.LogTrace(Resources.Trace_DetectedR, detected.Version, detected.Path); yield return detected; } } else { _logger.LogWarning(Resources.Error_NoRInterpreters); } } foreach (var kv in _options.Interpreters) { string id = kv.Key; InterpreterOptions options = kv.Value; if (!string.IsNullOrEmpty(options.BasePath) && _fs.DirectoryExists(options.BasePath)) { var interpInfo = new RInterpreterInfo(string.Empty, options.BasePath); if (interpInfo.VerifyInstallation()) { yield return new Interpreter(this, id, options.Name, interpInfo.InstallPath, interpInfo.BinPath, interpInfo.Version); continue; } } _logger.LogError(Resources.Error_FailedRInstallationData, id, options.BasePath); } }
public static void WriteGeneralData(TextWriter writer, bool detailed) { try { writer.WriteLine("OS Information"); writer.WriteLine(" Version: " + Environment.OSVersion); if (detailed) { writer.WriteLine(" CPU Count: " + Environment.ProcessorCount); writer.WriteLine(" 64 bit: " + Environment.Is64BitOperatingSystem); writer.WriteLine(" System Folder: " + Environment.SystemDirectory); writer.WriteLine(" Working set: " + Environment.WorkingSet); } writer.WriteLine(); Assembly thisAssembly = Assembly.GetExecutingAssembly(); writer.WriteLine("RTVS Information:"); writer.WriteLine(" Assembly: " + thisAssembly.FullName); if (detailed) { writer.WriteLine(" Codebase: " + thisAssembly.CodeBase); } writer.WriteLine(); var ri = new RInstallation(); var workflow = VsAppShell.Current.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>().GetOrCreate(); if (detailed) { var rEngines = ri.GetCompatibleEngines(); writer.WriteLine("Installed R Engines (from registry):"); foreach (var e in rEngines) { writer.WriteLine(Invariant($"{e.Name} {e.Version} {e.InstallPath}")); } writer.WriteLine(); var connections = workflow.Connections.RecentConnections; writer.WriteLine("Installed R Engines (from registry):"); foreach (var connection in connections) { writer.WriteLine(Invariant($" {connection.Name}: {connection.Path}")); } writer.WriteLine(); } var activeConnection = workflow.Connections.ActiveConnection; if (activeConnection != null) { writer.WriteLine("Active R URI:"); writer.WriteLine(Invariant($" {activeConnection.Name}: {activeConnection.Path}")); writer.WriteLine(); } if (detailed) { writer.WriteLine("Assemblies loaded by Visual Studio:"); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(assem => assem.FullName)) { var assemFileVersion = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).OfType<AssemblyFileVersionAttribute>().FirstOrDefault(); writer.WriteLine(string.Format(CultureInfo.InvariantCulture, " {0}, FileVersion={1}", assembly.FullName, assemFileVersion == null ? "(null)" : assemFileVersion.Version )); } } } catch (Exception ex) { writer.WriteLine(" Failed to access system data."); writer.WriteLine(ex.ToString()); writer.WriteLine(); } finally { writer.Flush(); } }
private Dictionary<string, IConnection> CreateConnectionList() { var connections = GetConnectionsFromSettings(); var localEngines = new RInstallation().GetCompatibleEngines().ToList(); // Remove missing engines and add engines missing from saved connections // Set 'is used created' to false if path points to locally found interpreter foreach (var kvp in connections.Where(c => !c.Value.IsRemote).ToList()) { var valid = IsValidLocalConnection(kvp.Value.Name, kvp.Value.Path); if (!valid) { connections.Remove(kvp.Key); } } // Add newly installed engines foreach (var e in localEngines) { if (!connections.Values.Any(x => x.Path.PathEquals(e.InstallPath))) { connections[e.Name] = CreateConnection(e.Name, e.InstallPath, string.Empty, isUserCreated: false); } } // Verify that most recently used connection is still valid var last = _settings.LastActiveConnection; if (last != null && !IsRemoteConnection(last.Path) && !IsValidLocalConnection(last.Name, last.Path)) { // Installation was removed or otherwise disappeared _settings.LastActiveConnection = null; } if (_settings.LastActiveConnection == null && connections.Any()) { // Perhaps first time launch with R preinstalled. var c = PickBestLocalRConnection(connections.Values, localEngines); _settings.LastActiveConnection = new ConnectionInfo(c.Name, c.Path, c.RCommandLineArguments, c.LastUsed, c.IsUserCreated); } return connections; }
private void ReportLocalRConfiguration() { // Report local R installations var engines = new RInstallation().GetCompatibleEngines(); foreach (var e in engines) { TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RInstallPath, e.InstallPath); } string rClientPath = SqlRClientInstallation.GetRClientPath(); if (rClientPath != null) { TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RClientFound); } var rEngines = GetRSubfolders("R"); foreach (var s in rEngines) { TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.REngine, s); } var rroEngines = GetRSubfolders("RRO"); foreach (var s in rroEngines) { TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RROEngine, s); } var mroEngines = GetRSubfolders("MRO"); foreach (var s in mroEngines) { TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.MROEngine, s); } if (_packageIndex != null) { foreach (var p in _packageIndex.Packages) { TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RPackages, new TelemetryPiiProperty(p.Name)); } } }
public void BrowseLocalPath(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection == null) { return; } string latestLocalPath; Uri latestLocalPathUri; if (connection.Path != null && Uri.TryCreate(connection.Path, UriKind.Absolute, out latestLocalPathUri) && latestLocalPathUri.IsFile && !latestLocalPathUri.IsUnc) { latestLocalPath = latestLocalPathUri.LocalPath; } else { latestLocalPath = Environment.SystemDirectory; try { latestLocalPath = new RInstallation().GetCompatibleEngines().FirstOrDefault()?.InstallPath; if (string.IsNullOrEmpty(latestLocalPath) || !Directory.Exists(latestLocalPath)) { // Force 64-bit PF latestLocalPath = Environment.GetEnvironmentVariable("ProgramW6432"); } } catch (ArgumentException) { } catch (IOException) { } } var path = _shell.FileDialog.ShowBrowseDirectoryDialog(latestLocalPath); if (path != null) { // Verify path var ri = new RInterpreterInfo(string.Empty, path); if (ri.VerifyInstallation(null, null, _shell)) { connection.Path = path; } } }