public static IRInterpreterInfo GetMicrosoftRClientInfo(IRegistry registry = null, IFileSystem fileSystem = null) { registry = registry ?? new RegistryImpl(); fileSystem = fileSystem ?? new FileSystem(); // If yes, check 32-bit registry for R engine installed by the R Server. // TODO: remove this when MRS starts writing 64-bit keys. if (IsMRCInstalledInSql(registry)) { using (IRegistryKey hklm = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) { try { using (var key = hklm.OpenSubKey(@"SOFTWARE\R-core\R64")) { foreach (var keyName in key.GetSubKeyNames()) { using (var rsKey = key.OpenSubKey(keyName)) { try { var path = (string)rsKey?.GetValue("InstallPath"); if (!string.IsNullOrEmpty(path) && path.Contains(_rServer)) { var info = new RInterpreterInfo(string.Empty, path); if (info.VerifyInstallation(new SupportedRVersionRange(), fileSystem)) { return new RInterpreterInfo(Invariant($"Microsoft R Client (SQL) {info.Version.Major}.{info.Version.Minor}.{info.Version.Build}"), info.InstallPath); } } } catch (Exception) { } } } } } catch (Exception) { } } } return null; }
public static IRInterpreterInfo GetMicrosoftRClientInfo(IRegistry registry = null, IFileSystem fileSystem = null) { registry = registry ?? new RegistryImpl(); fileSystem = fileSystem ?? new FileSystem(); // If yes, check 32-bit registry for R engine installed by the R Server. // TODO: remove this when MRS starts writing 64-bit keys. if (IsMRCInstalledInSql(registry)) { using (IRegistryKey hklm = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) { try { using (var key = hklm.OpenSubKey(@"SOFTWARE\R-core\R64")) { foreach (var keyName in key.GetSubKeyNames()) { using (var rsKey = key.OpenSubKey(keyName)) { try { var path = (string)rsKey?.GetValue("InstallPath"); if (!string.IsNullOrEmpty(path) && path.Contains(_rServer)) { var info = new RInterpreterInfo(string.Empty, path); if (info.VerifyInstallation(new SupportedRVersionRange(), fileSystem)) { return(new RInterpreterInfo(Invariant($"Microsoft R Client (SQL) {info.Version.Major}.{info.Version.Minor}.{info.Version.Build}"), info.InstallPath)); } } } catch (Exception) { } } } } } catch (Exception) { } } } return(null); }
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); } }
private IEnumerable <IRInterpreterInfo> GetInstalledCranR(IEnumerable <InstalledPackageInfo> packagesInfo, ISupportedRVersionRange svl) { var selectedPackages = packagesInfo.Where(p => p.PackageName.EqualsIgnoreCase("r-base-core") && svl.IsCompatibleVersion(p.GetVersion())); foreach (var package in selectedPackages) { yield return(RInterpreterInfo.CreateFromPackage(package, "CRAN R", _fileSystem)); } }
private IEnumerable <IRInterpreterInfo> GetInstalledMRO(IEnumerable <InstalledPackageInfo> packagesInfo, ISupportedRVersionRange svl) { var selectedPackages = packagesInfo.Where(p => p.PackageName.StartsWithIgnoreCase("microsoft-r-open-mro") && svl.IsCompatibleVersion(p.GetVersion())); foreach (var package in selectedPackages) { yield return(RInterpreterInfo.CreateFromPackage(package, "Microsoft R Open", _fileSystem)); } }
private IRInterpreterInfo TryFindRInProgramFiles(ISupportedRVersionRange supportedVersions) { // Force 64-bit PF var programFiles = Environment.GetEnvironmentVariable("ProgramW6432"); var baseRFolder = Path.Combine(programFiles, @"R"); var versions = new List <Version>(); try { if (_fileSystem.DirectoryExists(baseRFolder)) { IEnumerable <IFileSystemInfo> directories = _fileSystem.GetDirectoryInfo(baseRFolder) .EnumerateFileSystemInfos() .Where(x => (x.Attributes & FileAttributes.Directory) != 0); foreach (IFileSystemInfo fsi in directories) { string subFolderName = fsi.FullName.Substring(baseRFolder.Length + 1); Version v = GetRVersionFromFolderName(subFolderName); if (supportedVersions.IsCompatibleVersion(v)) { versions.Add(v); } } } } catch (IOException) { // Don't do anything if there is no RRO installed } if (versions.Count > 0) { versions.Sort(); Version highest = versions[versions.Count - 1]; var name = string.Format(CultureInfo.InvariantCulture, "R-{0}.{1}.{2}", highest.Major, highest.Minor, highest.Build); var path = Path.Combine(baseRFolder, name); var ri = new RInterpreterInfo(name, path); if (ri.VerifyInstallation(supportedVersions)) { return(ri); } } return(null); }
private bool IsValidLocalConnection(string name, string path) { try { var info = new RInterpreterInfo(name, path); return info.VerifyInstallation(); } catch (Exception ex) when (!ex.IsCriticalException()) { _shell.Services.Log.WriteAsync(LogVerbosity.Normal, MessageCategory.Error, ex.Message).DoNotWait(); } return false; }
private IRInterpreterInfo TryFindRInProgramFiles(ISupportedRVersionRange supportedVersions) { // Force 64-bit PF var programFiles = Environment.GetEnvironmentVariable("ProgramW6432"); var baseRFolder = Path.Combine(programFiles, @"R"); var versions = new List<Version>(); try { if (_fileSystem.DirectoryExists(baseRFolder)) { IEnumerable<IFileSystemInfo> directories = _fileSystem.GetDirectoryInfo(baseRFolder) .EnumerateFileSystemInfos() .Where(x => (x.Attributes & FileAttributes.Directory) != 0); foreach (IFileSystemInfo fsi in directories) { string subFolderName = fsi.FullName.Substring(baseRFolder.Length + 1); Version v = GetRVersionFromFolderName(subFolderName); if (supportedVersions.IsCompatibleVersion(v)) { versions.Add(v); } } } } catch (IOException) { // Don't do anything if there is no RRO installed } if (versions.Count > 0) { versions.Sort(); Version highest = versions[versions.Count - 1]; var name = string.Format(CultureInfo.InvariantCulture, "R-{0}.{1}.{2}", highest.Major, highest.Minor, highest.Build); var path = Path.Combine(baseRFolder, name); var ri = new RInterpreterInfo(name, path); if (ri.VerifyInstallation(supportedVersions)) { return ri; } } return null; }
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; } } }