예제 #1
0
        private void TestPlatform(string brokerSubPath, string hostSubPath, OSPlatform platform)
        {
            var locator    = new BrokerExecutableLocator(_fs, platform);
            var brokerPath = Path.Combine(locator.BaseDirectory, brokerSubPath);
            var hostPath   = Path.Combine(locator.BaseDirectory, hostSubPath);

            _fs.FileExists(brokerPath).Returns(true);
            locator.GetBrokerExecutablePath().Should().Be(brokerPath);
            locator.GetHostExecutablePath().Should().BeNull();

            _fs.FileExists(hostPath).Returns(true);
            locator.GetBrokerExecutablePath().Should().Be(brokerPath);
            locator.GetHostExecutablePath().Should().Be(hostPath);
        }
예제 #2
0
        public void Empty()
        {
            var locator = new BrokerExecutableLocator(_fs, OSPlatform.Windows);

            locator.GetBrokerExecutablePath().Should().BeNull();
            locator.GetHostExecutablePath().Should().BeNull();
        }
        public IProcess StartHost(string interpreterPath, string interpreterArchitecture, string commandLine)
        {
            var exeLocator = new BrokerExecutableLocator(_fs);

            var hostBinPath = exeLocator.GetHostExecutablePath(interpreterArchitecture);

            if (hostBinPath == null)
            {
                throw new Win32Exception($"Microsoft.R.Host is missing. Interpreter: {interpreterPath}. Architecture: {interpreterArchitecture}");
            }

            var psi = new ProcessStartInfo {
                FileName               = hostBinPath,
                Arguments              = commandLine,
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                WorkingDirectory       = Environment.GetEnvironmentVariable("PWD")
            };

            psi.Environment.Add("R_HOME", interpreterPath);
            psi.Environment.Add("LD_LIBRARY_PATH", Path.Combine(interpreterPath, "lib"));

            var process = _ps.Start(psi);

            process.WaitForExit(250);
            if (process.HasExited && process.ExitCode != 0)
            {
                throw new Win32Exception(process.ExitCode);
            }
            return(process);
        }