コード例 #1
0
ファイル: RPackageData.cs プロジェクト: sandboxorg/RTVS
        /// <summary>
        /// Retrieves hashes for all R package names in a given folder
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <string> GetInstalledPackageHashes(RPackageType packageType)
        {
            string rInstallPath = RInstallation.GetRInstallPath(RToolsSettings.Current.RBasePath, null, VsAppShell.Current);

            if (!string.IsNullOrEmpty(rInstallPath))
            {
                IEnumerable <string> packageNames = Enumerable.Empty <string>();
                if (packageType == RPackageType.Base)
                {
                    packageNames = FolderUtility.GetSubfolderRelativePaths(Path.Combine(rInstallPath, "library"));
                }
                else
                {
                    Version v = RInstallation.GetRVersionFromFolderName(rInstallPath.Substring(rInstallPath.LastIndexOf('\\') + 1));
                    if (v.Major > 0)
                    {
                        string userLibraryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                                              @"R\win-library\", v.Major.ToString() + "." + v.Minor.ToString());

                        packageNames = FolderUtility.GetSubfolderRelativePaths(userLibraryPath);
                    }
                }

                foreach (string p in packageNames)
                {
                    string hash = CalculateMD5Hash(p);
                    yield return(hash);
                }
            }
        }
コード例 #2
0
 public RToolsSettingsImplementation()
 {
     // Default settings. Will be overwritten with actual
     // settings (if any) when settings are loaded from storage
     RBasePath         = RInstallation.GetRInstallPath(null, null);
     _workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 }
コード例 #3
0
        private static string GetInstallPath()
        {
            var    basePath     = RToolsSettings.Current != null ? RToolsSettings.Current.RBasePath : null;
            string rInstallPath = RInstallation.GetRInstallPath(basePath, new SupportedRVersionRange());

            return(rInstallPath != null?Path.Combine(rInstallPath, "library") : null);
        }
コード例 #4
0
        private static string CollectGeneralData()
        {
            string generalDataFile = Path.Combine(Path.GetTempPath(), RtvsGeneralDataFile);

            using (var sw = new StreamWriter(generalDataFile)) {
                try {
                    sw.WriteLine("Operating System Information");
                    sw.WriteLine("    Version:       " + Environment.OSVersion.ToString());
                    sw.WriteLine("    CPU Count:     " + Environment.ProcessorCount);
                    sw.WriteLine("    64 bit:        " + Environment.Is64BitOperatingSystem);
                    sw.WriteLine("    System Folder: " + Environment.SystemDirectory);
                    sw.WriteLine("    Working set:   " + Environment.WorkingSet);
                    sw.WriteLine();

                    Assembly thisAssembly = Assembly.GetExecutingAssembly();
                    sw.WriteLine("RTVS Information:");
                    sw.WriteLine("    Assembly: " + thisAssembly.FullName);
                    sw.WriteLine("    Codebase: " + thisAssembly.CodeBase);
                    sw.WriteLine();

                    IEnumerable <string> rEngines = RInstallation.GetInstalledEngineVersionsFromRegistry();
                    sw.WriteLine("Installed R Engines (from registry):");
                    foreach (string e in rEngines)
                    {
                        sw.WriteLine("    " + e);
                    }
                    sw.WriteLine();

                    string latestEngine = RInstallation.GetCompatibleEnginePathFromRegistry();
                    sw.WriteLine("Latest R Engine (from registry):");
                    sw.WriteLine("    " + latestEngine);
                    sw.WriteLine();

                    string rInstallPath = RInstallation.GetRInstallPath(RToolsSettings.Current.RBasePath);
                    sw.WriteLine("R Install path:");
                    sw.WriteLine("    " + rInstallPath);
                    sw.WriteLine();

                    sw.WriteLine("Loaded assemblies:");

                    foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(assem => assem.FullName))
                    {
                        var assemFileVersion = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).OfType <AssemblyFileVersionAttribute>().FirstOrDefault();

                        sw.WriteLine(string.Format(CultureInfo.InvariantCulture, "    {0}, FileVersion={1}",
                                                   assembly.FullName,
                                                   assemFileVersion == null ? "(null)" : assemFileVersion.Version
                                                   ));
                    }
                } catch (System.Exception ex) {
                    sw.WriteLine("  Failed to access system data.");
                    sw.WriteLine(ex.ToString());
                    sw.WriteLine();
                }
            }

            return(generalDataFile);
        }
コード例 #5
0
ファイル: RtvsTelemetry.cs プロジェクト: CarlosMeloStuff/RTVS
        public void ReportConfiguration()
        {
            if (TelemetryService.IsEnabled)
            {
                try {
                    Assembly thisAssembly = Assembly.GetExecutingAssembly();
                    TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RtvsVersion, thisAssembly.GetName().Version.ToString());

                    string rInstallPath = RInstallation.GetRInstallPath(RToolsSettings.Current.RBasePath);
                    TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RInstallPath, rInstallPath);

                    string rClientPath = MicrosoftRClient.GetRClientPath();
                    if (rClientPath != null)
                    {
                        TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RClientFound);
                        if (rInstallPath != null && rInstallPath.EqualsIgnoreCase(rClientPath))
                        {
                            TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RClientActive);
                        }
                    }

                    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);
                    }

                    var hashes = RPackageData.GetInstalledPackageHashes(RPackageType.Base);
                    foreach (var s in hashes)
                    {
                        TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RBasePackages, s);
                    }

                    hashes = RPackageData.GetInstalledPackageHashes(RPackageType.User);
                    foreach (var s in hashes)
                    {
                        TelemetryService.ReportEvent(TelemetryArea.Configuration, ConfigurationEvents.RUserPackages, s);
                    }
                } catch (Exception ex) {
                    Trace.Fail("Telemetry exception: " + ex.Message);
                }
            }
        }
コード例 #6
0
ファイル: RSession.cs プロジェクト: CarlosMeloStuff/RTVS
 private async Task CreateAndRunHost(RHostStartupInfo startupInfo, int timeout)
 {
     try {
         await _host.CreateAndRun(RInstallation.GetRInstallPath(startupInfo.RBasePath, new SupportedRVersionRange()), startupInfo.RHostDirectory, startupInfo.RHostCommandLineArguments, timeout);
     } catch (OperationCanceledException oce) {
         _initializationTcs.TrySetCanceled(oce.CancellationToken);
     } catch (Exception ex) {
         _initializationTcs.TrySetException(ex);
     } finally {
         Interlocked.Exchange(ref _initializationTcs, null);
     }
 }
コード例 #7
0
ファイル: RInstallationTest.cs プロジェクト: sandboxorg/RTVS
        public void MsRClient()
        {
            var rClientInstallPath = @"C:\Program Files\Microsoft\R Client\";
            var rClientRPath       = @"C:\Program Files\Microsoft\R Client\R_SERVER\";
            var tr = new RegistryMock(SimulateRegistryMsRClient(rClientInstallPath, rClientRPath));

            RInstallation.Registry = tr;

            RInstallation.GetRClientPath().Should().Be(rClientRPath);

            var shell = Substitute.For <ICoreShell>();

            shell.ShowMessage(Arg.Any <string>(), Arg.Any <MessageButtons>()).Returns(MessageButtons.Yes);

            RInstallation.GetRInstallPath(null, null, shell).Should().Be(rClientRPath);
            shell.Received(1).ShowMessage(Arg.Any <string>(), Arg.Any <MessageButtons>());

            RInstallation.GetRInstallPath(null, null, shell).Should().Be(rClientRPath);
            shell.Received(1).ShowMessage(Arg.Any <string>(), Arg.Any <MessageButtons>());
        }
コード例 #8
0
ファイル: DiagnosticLogs.cs プロジェクト: xoriath/RTVS
        public static void WriteGeneralData(TextWriter writer, bool detailed)
        {
            try {
                writer.WriteLine("OS Information");
                writer.WriteLine("    Version:       " + Environment.OSVersion.ToString());
                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();

                if (detailed)
                {
                    IEnumerable <string> rEngines = RInstallation.GetInstalledEngineVersionsFromRegistry();
                    writer.WriteLine("Installed R Engines (from registry):");
                    foreach (string e in rEngines)
                    {
                        writer.WriteLine("    " + e);
                    }
                    writer.WriteLine();

                    string latestEngine = RInstallation.GetCompatibleEnginePathFromRegistry();
                    writer.WriteLine("Latest R Engine (from registry):");
                    writer.WriteLine("    " + latestEngine);
                    writer.WriteLine();
                }

                string rInstallPath = RInstallation.GetRInstallPath(RToolsSettings.Current.RBasePath);
                writer.WriteLine("R Install path:");
                writer.WriteLine("    " + rInstallPath);
                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 (System.Exception ex) {
                writer.WriteLine("  Failed to access system data.");
                writer.WriteLine(ex.ToString());
                writer.WriteLine();
            } finally {
                writer.Flush();
            }
        }
コード例 #9
0
        private static string GetInstallPath()
        {
            string rInstallPath = RInstallation.GetRInstallPath(RToolsSettings.Current != null ? RToolsSettings.Current.RBasePath : null);

            return(rInstallPath != null?Path.Combine(rInstallPath, "library") : null);
        }