示例#1
0
 private PythonRpc(IProcessServices procServices, IProcess process) : base(process.StandardInput.BaseStream, process.StandardOutput.BaseStream)
 {
     _procServices = procServices;
     _process      = process;
     Disconnected += PythonRpc_Disconnected;
     StartListening();
 }
示例#2
0
 public PreviewWordCommand(
     ITextView textView,
     IRInteractiveWorkflowProvider workflowProvider,
     IApplicationShell appShell,
     IProcessServices pss,
     IFileSystem fs) :
     base(textView, (int)MdPackageCommandId.icmdPreviewWord, workflowProvider, appShell, pss, fs) { }
示例#3
0
 public WebBrowserServices(ICoreShell coreShell)
 {
     _coreShell = coreShell;
     _wbs       = _coreShell.GetService <IVsWebBrowsingService>(typeof(SVsWebBrowsingService));
     _ps        = _coreShell.Process();
     _settings  = _coreShell.GetService <IRToolsSettings>();
 }
示例#4
0
 public PreviewPdfCommand(
     ITextView textView,
     IRInteractiveWorkflowProvider workflowProvider,
     ICoreShell coreShell,
     IProcessServices pss,
     IFileSystem fs)
     : base(textView, (int)MdPackageCommandId.icmdPreviewPdf, workflowProvider, coreShell, pss, fs)
 {
 }
示例#5
0
 public PreviewWordCommand(
     ITextView textView,
     IRInteractiveWorkflowProvider workflowProvider,
     IApplicationShell appShell,
     IProcessServices pss,
     IFileSystem fs) :
     base(textView, (int)MdPackageCommandId.icmdPreviewWord, workflowProvider, appShell, pss, fs)
 {
 }
示例#6
0
 public RemoteBrokerProcess(string name, string logFolder, IFileSystem fileSystem, IRInstallationService installations, IProcessServices processServices)
 {
     _name            = name;
     _logFolder       = logFolder;
     _fileSystem      = fileSystem;
     _installations   = installations;
     _processServices = processServices;
     _rhostDirectory  = Path.GetDirectoryName(typeof(RHost).Assembly.GetAssemblyPath());
     Password         = Guid.NewGuid().ToString();
 }
示例#7
0
 public PreviewHtmlCommand(
     ITextView textView,
     IRInteractiveWorkflowProvider workflowProvider,
     IApplicationShell appShell,
     IProcessServices pss,
     IFileSystem fs,
     IWebBrowserServices wbs)
     : base(textView, (int)MdPackageCommandId.icmdPreviewHtml,
           workflowProvider, appShell, pss, fs) {
     _wbs = wbs;
 }
示例#8
0
        private static IProcess CreateRunAsUserProcess(IProcessServices ps, bool quietMode)
        {
            var psi = new ProcessStartInfo {
                FileName               = PathConstants.RunAsUserBinPath,
                Arguments              = quietMode ? "-q" : "",
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true
            };

            return(ps.Start(psi));
        }
示例#9
0
        private static Process CreateRunAsUserProcess(IProcessServices ps, bool quietMode)
        {
            ProcessStartInfo psi = new ProcessStartInfo();

            psi.FileName               = PathConstants.RunAsUserBinPath;
            psi.Arguments              = quietMode ? "-q" : "";
            psi.RedirectStandardError  = true;
            psi.RedirectStandardInput  = true;
            psi.RedirectStandardOutput = true;

            return(ps.Start(psi));
        }
示例#10
0
 public PreviewHtmlCommand(
     ITextView textView,
     IRInteractiveWorkflowProvider workflowProvider,
     ICoreShell coreShell,
     IProcessServices pss,
     IFileSystem fs,
     IWebBrowserServices wbs)
     : base(textView, (int)MdPackageCommandId.icmdPreviewHtml,
            workflowProvider, coreShell, pss, fs)
 {
     _wbs = wbs;
 }
示例#11
0
 public static ICoreServices CreateSubstitute(ILoggingPermissions loggingPermissions = null, IFileSystem fs = null, IRegistry registry = null, IProcessServices ps = null) {
     return new CoreServices(
         Substitute.For<IApplicationConstants>(),
         Substitute.For<ITelemetryService>(),
         loggingPermissions,
         Substitute.For<ISecurityService>(),
         Substitute.For<ITaskService>(),
         UIThreadHelper.Instance,
         Substitute.For<IActionLog>(),
         fs ?? Substitute.For<IFileSystem>(),
         registry ?? Substitute.For<IRegistry>(),
         ps ?? Substitute.For<IProcessServices>());
 }
示例#12
0
            public static PythonRpc Create(IProcessServices procServices, string exe, params string[] args)
            {
                var startInfo = new ProcessStartInfo(exe, args.AsQuotedArguments())
                {
                    UseShellExecute        = false,
                    ErrorDialog            = false,
                    CreateNoWindow         = true,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                };

                var process = procServices.Start(startInfo);

                return(new PythonRpc(procServices, process));
            }
示例#13
0
        public PreviewCommand(ITextView textView, int id,
            IRInteractiveWorkflowProvider workflowProvider,
            IApplicationShell appShell,
            IProcessServices pss,
            IFileSystem fs)
            : base(textView, new CommandId[] { new CommandId(MdPackageCommandId.MdCmdSetGuid, id) }, false) {
            _workflowProvider = workflowProvider;
            AppShell = appShell;
            _pss = pss;
            _fs = fs;

            IEnumerable<Lazy<IMarkdownFlavorPublishHandler>> handlers = AppShell.ExportProvider.GetExports<IMarkdownFlavorPublishHandler>();
            foreach (var h in handlers) {
                _flavorHandlers[h.Value.Flavor] = h.Value;
            }
        }
示例#14
0
        private static Process CreateRLaunchProcess(IProcessServices ps, bool authenticateOnly)
        {
            // usage:
            // Microsoft.R.Host.RunAsUser [-q]
            //    -q: Quiet
            const string rLaunchPath = "/usr/lib/rtvs/Microsoft.R.Host.RunAsUser";

            ProcessStartInfo psi = new ProcessStartInfo();

            psi.FileName               = rLaunchPath;
            psi.Arguments              = authenticateOnly ? "" : "-q";
            psi.RedirectStandardError  = true;
            psi.RedirectStandardInput  = true;
            psi.RedirectStandardOutput = true;

            return(ps.Start(psi));
        }
示例#15
0
        protected PreviewCommand(ITextView textView, int id,
                                 IRInteractiveWorkflowVisualProvider workflowProvider, IServiceContainer services)
            : base(textView, new CommandId[] { new CommandId(MdPackageCommandId.MdCmdSetGuid, id) }, false)
        {
            _workflowProvider = workflowProvider;
            Services          = services;
            _fs  = services.FileSystem();
            _pss = services.Process();

            var exp      = services.GetService <ExportProvider>();
            var handlers = exp.GetExports <IMarkdownFlavorPublishHandler>();

            foreach (var h in handlers)
            {
                _flavorHandlers[h.Value.Flavor] = h.Value;
            }
        }
示例#16
0
        public static IProcess RunAsCurrentUser(IProcessServices ps, string hostBinPath, string arguments, string rHomePath, string loadLibPath)
        {
            var psi = new ProcessStartInfo {
                FileName               = hostBinPath,
                Arguments              = arguments,
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                WorkingDirectory       = Environment.GetEnvironmentVariable("PWD")
            };

            // All other should be same as the broker environment. Only these are set based on interpreters.
            // R_HOME is explicitly set on the R-Host.
            psi.Environment.Add("R_HOME", rHomePath);
            psi.Environment.Add("LD_LIBRARY_PATH", loadLibPath);

            return(ps.Start(psi));
        }
示例#17
0
        public static Process AuthenticateAndRunAsUser(ILogger <Session> logger, IProcessServices ps, string username, string password, string profileDir, IEnumerable <string> arguments, IDictionary <string, string> environment)
        {
            Process proc = CreateRLaunchProcess(ps, false);

            using (BinaryWriter writer = new BinaryWriter(proc.StandardInput.BaseStream, Encoding.UTF8, true)) {
                var message = new AuthenticateAndRunMessage()
                {
                    Username = username, Password = password, Arguments = arguments, Environment = environment.Select(e => $"{e.Key}={e.Value}")
                };
                string json      = JsonConvert.SerializeObject(message, GetJsonSettings());
                var    jsonBytes = Encoding.UTF8.GetBytes(json);
                writer.Write(jsonBytes.Length);
                writer.Write(jsonBytes);
                writer.Flush();
            }

            return(proc);
        }
示例#18
0
        public PreviewCommand(ITextView textView, int id,
                              IRInteractiveWorkflowProvider workflowProvider,
                              ICoreShell coreShell,
                              IProcessServices pss,
                              IFileSystem fs)
            : base(textView, new CommandId[] { new CommandId(MdPackageCommandId.MdCmdSetGuid, id) }, false)
        {
            _workflowProvider = workflowProvider;
            _coreShell        = coreShell;
            _pss = pss;
            _fs  = fs;

            IEnumerable <Lazy <IMarkdownFlavorPublishHandler> > handlers = _coreShell.ExportProvider.GetExports <IMarkdownFlavorPublishHandler>();

            foreach (var h in handlers)
            {
                _flavorHandlers[h.Value.Flavor] = h.Value;
            }
        }
示例#19
0
 private void AddBasicServices(IActionLog log = null
                               , ILoggingPermissions loggingPermissions = null
                               , IFileSystem fs      = null
                               , IRegistry registry  = null
                               , IProcessServices ps = null)
 {
     ServiceManager
     .AddService(UIThreadHelper.Instance)
     .AddService(log ?? Substitute.For <IActionLog>())
     .AddService(new SecurityServiceStub())
     .AddService(loggingPermissions ?? Substitute.For <ILoggingPermissions>())
     .AddService(fs ?? new WindowsFileSystem())
     .AddService(registry ?? new RegistryImpl())
     .AddService(ps ?? new ProcessServices())
     .AddService(new TestTaskService())
     .AddService(new TestUIServices())
     .AddService(new TestImageService())
     .AddService(new TestPlatformServices());
 }
示例#20
0
        public CoreServices(IApplicationConstants appConstants
                            , ITelemetryService telemetry
                            , ITaskService tasks
                            , IProcessServices processServices
                            , ILoggingPermissions loggingPermissions
                            , IMainThread mainThread
                            , ISecurityService security)
        {
            LoggingPermissions = loggingPermissions;
            Telemetry          = telemetry;
            Security           = security;
            Tasks = tasks;

            ProcessServices = processServices;
            FileSystem      = new FileSystem();
            MainThread      = mainThread;

            Log = new Logger(appConstants.ApplicationName, Path.GetTempPath(), LoggingPermissions);
        }
示例#21
0
        public CoreServices(
            IApplicationConstants appConstants
            , ITelemetryService telemetry
            , ILoggingPermissions permissions
            , ISecurityService security
            , [Import(AllowDefault = true)] IActionLog log      = null
            , [Import(AllowDefault = true)] IFileSystem fs      = null
            , [Import(AllowDefault = true)] IRegistry registry  = null
            , [Import(AllowDefault = true)] IProcessServices ps = null)
        {
            LoggingServices = new LoggingServices(permissions, appConstants);
            _appConstants   = appConstants;
            _log            = log;

            Telemetry       = telemetry;
            Security        = security;
            ProcessServices = ps ?? new ProcessServices();
            Registry        = registry ?? new RegistryImpl();
            FileSystem      = fs ?? new FileSystem();
        }
示例#22
0
        private static Process CreateRLaunchProcess(IProcessServices ps, bool authenticateOnly)
        {
            // usage:
            // Microsoft.R.Host.RunAsUser [-q]
            //    -q: Quiet
            const string rLaunchBinary = "Microsoft.R.Host.RunAsUser";

            string brokerDir   = Path.GetDirectoryName(typeof(Program).GetTypeInfo().Assembly.Location);
            string rLaunchPath = Path.Combine(brokerDir, rLaunchBinary);

            ProcessStartInfo psi = new ProcessStartInfo();

            psi.FileName               = rLaunchPath;
            psi.Arguments              = authenticateOnly ? "" : "-q";
            psi.RedirectStandardError  = true;
            psi.RedirectStandardInput  = true;
            psi.RedirectStandardOutput = true;

            return(ps.Start(psi));
        }
示例#23
0
        public CoreServices(ITelemetryService telemetry
                            , ILoggingPermissions permissions
                            , ISecurityService security
                            , ITaskService tasks
                            , IMainThread mainThread
                            , IActionLog log
                            , IFileSystem fs
                            , IProcessServices ps)
        {
            LoggingPermissions = permissions;
            Log = log;

            Telemetry = telemetry;
            Security  = security;
            Tasks     = tasks;

            Process    = ps;
            FileSystem = fs;
            MainThread = mainThread;
        }
示例#24
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices) {
            await appShell.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0) {
                return;
            }

            var workflow = appShell.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>().GetOrCreate();
            var session = workflow.RSession;

            var folder = GetTempCsvFilesFolder();
            if (!Directory.Exists(folder)) {
                Directory.CreateDirectory(folder);
            }

            var pss = appShell.ExportProvider.GetExportedValue<IProjectSystemServices>();
            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName = MakeCsvFileName(appShell, pss, variableName);

            var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var statusBar = appShell.GetGlobalService<IVsStatusbar>(typeof(SVsStatusbar));
            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                appShell.ProgressDialog.Show(async (p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p, ct), Resources.Status_WritingCSV, 100, 500);
                if (fileSystem.FileExists(file)) {
                    processServices.Start(file);
                }
            } catch (Exception ex) when (ex is Win32Exception || ex is IOException || ex is UnauthorizedAccessException) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
示例#25
0
        public CoreServices(IApplicationConstants appConstants
            , ITelemetryService telemetry
            , ILoggingPermissions permissions
            , ISecurityService security
            , ITaskService tasks
            , IMainThread mainThread
            , IActionLog log
            , IFileSystem fs
            , IRegistry registry
            , IProcessServices ps) {

            LoggingServices = new LoggingServices(permissions, appConstants);
            Log = log;

            Telemetry = telemetry;
            Security = security;
            Tasks = tasks;

            ProcessServices = ps;
            Registry = registry;
            FileSystem = fs;
            MainThread = mainThread;
        }
示例#26
0
 private void AddBasicServices(IActionLog log = null
                               , ILoggingPermissions loggingPermissions = null
                               , IFileSystem fs      = null
                               , IRegistry registry  = null
                               , IProcessServices ps = null)
 {
     ServiceManager
     .AddService(this)
     .AddService(UIThreadHelper.Instance.MainThread)
     .AddService(log ?? Substitute.For <IActionLog>())
     .AddService(new SecurityServiceStub())
     .AddService(loggingPermissions ?? Substitute.For <ILoggingPermissions>())
     .AddService(fs ?? new WindowsFileSystem())
     .AddService <IOutputService, TestOutputService>()
     .AddService(registry ?? new RegistryImpl())
     .AddService(ps ?? new WindowsProcessServices())
     .AddService(UIThreadHelper.Instance.TaskService)
     .AddService(new TestUIServices(UIThreadHelper.Instance.ProgressDialog))
     .AddService(new TestImageService())
     .AddService(new TestPlatformServices())
     .AddService(new TestApplication())
     .AddService(new TestIdleTimeService());
 }
示例#27
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result, ICoreShell shell, IFileSystem fileSystem, IProcessServices processServices)
        {
            await shell.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0)
            {
                return;
            }

            var workflow = shell.GetService <IRInteractiveWorkflowProvider>().GetOrCreate();
            var session  = workflow.RSession;

            var folder = GetTempCsvFilesFolder();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var pss          = shell.GetService <IProjectSystemServices>();
            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName  = MakeCsvFileName(shell, pss, variableName);

            var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var    statusBar = shell.GetService <IVsStatusbar>(typeof(SVsStatusbar));

            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                shell.ProgressDialog().Show(async(p, ct) => await CreateCsvAndStartProcess(result, session, shell, file, fileSystem, p, ct), Resources.Status_WritingCSV, 100, 500);
                if (fileSystem.FileExists(file))
                {
                    processServices.Start(file);
                }
            } catch (Exception ex) when(ex is Win32Exception || ex is IOException || ex is UnauthorizedAccessException)
            {
                shell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
 public UnixRHostProcessService(ILogger <Session> sessionLogger, IProcessServices ps)
 {
     _sessionLogger = sessionLogger;
     _ps            = ps;
 }
示例#29
0
 public PlatformProcess(IProcessServices ps, Process process)
 {
     _ps      = ps;
     _process = process;
 }
示例#30
0
 public static ICoreServices CreateSubstitute(ILoggingPermissions loggingPermissions = null, IFileSystem fs = null, IRegistry registry = null, IProcessServices ps = null)
 {
     return(new CoreServices(
                Substitute.For <ITelemetryService>(),
                loggingPermissions,
                Substitute.For <ISecurityService>(),
                Substitute.For <ITaskService>(),
                UIThreadHelper.Instance,
                Substitute.For <IActionLog>(),
                fs ?? Substitute.For <IFileSystem>(),
                registry ?? Substitute.For <IRegistry>(),
                ps ?? Substitute.For <IProcessServices>()));
 }
示例#31
0
 public ReportIssueCommand(ICoreServices services)
     : base(RGuidList.RCmdSetGuid, RPackageCommandId.icmdReportIssue)
 {
     _permissions = services.LoggingPermissions;
     _pss         = services.ProcessServices;
 }
示例#32
0
 public LinuxSystemInfoService(ILogger <ISystemInfoService> logger, IFileSystem fs, IProcessServices ps)
 {
     _logger = logger;
     _fs     = fs;
     _ps     = ps;
 }
示例#33
0
        public static bool AuthenticateUser(ILogger <IAuthenticationService> logger, IProcessServices ps, string username, string password, string allowedGroup, out string profileDir)
        {
            bool    retval  = false;
            Process proc    = null;
            string  userDir = string.Empty;

            try {
                proc = CreateRunAsUserProcess(ps, false);
                using (BinaryWriter writer = new BinaryWriter(proc.StandardInput.BaseStream, Encoding.UTF8, true))
                    using (BinaryReader reader = new BinaryReader(proc.StandardOutput.BaseStream, Encoding.UTF8, true)) {
                        var message = new AuthenticationOnlyMessage()
                        {
                            Username = GetUnixUserName(username), Password = password, AllowedGroup = allowedGroup
                        };
                        string json      = JsonConvert.SerializeObject(message, GetJsonSettings());
                        var    jsonBytes = Encoding.UTF8.GetBytes(json);
                        writer.Write(jsonBytes.Length);
                        writer.Write(jsonBytes);
                        writer.Flush();

                        proc.WaitForExit(3000);

                        if (proc.HasExited && proc.ExitCode == 0)
                        {
                            int size  = reader.ReadInt32();
                            var bytes = reader.ReadBytes(size);
                            var arr   = JsonConvert.DeserializeObject <JArray>(Encoding.UTF8.GetString(bytes));
                            if (arr.Count > 1)
                            {
                                var respType = arr[0].Value <string>();
                                switch (respType)
                                {
                                case PamInfo:
                                case PamError:
                                    var pam = arr[1].Value <string>();
                                    logger.LogCritical(Resources.Error_PAMAuthenticationError.FormatInvariant(pam));
                                    break;

                                case JsonError:
                                    var jerror = arr[1].Value <string>();
                                    logger.LogCritical(Resources.Error_RunAsUserJsonError.FormatInvariant(jerror));
                                    break;

                                case RtvsResult:
                                    userDir = arr[1].Value <string>();
                                    retval  = true;
                                    if (userDir.Length == 0)
                                    {
                                        logger.LogError(Resources.Error_NoProfileDir);
                                    }
                                    break;

                                case RtvsError:
                                    var resource = arr[1].Value <string>();
                                    logger.LogCritical(Resources.Error_RunAsUserFailed.FormatInvariant(Resources.ResourceManager.GetString(resource)));
                                    break;
                                }
                            }
                            else
                            {
                                logger.LogCritical(Resources.Error_InvalidRunAsUserResponse);
                            }
                        }
                        else
                        {
                            logger.LogCritical(Resources.Error_AuthFailed, GetRLaunchExitCodeMessage(proc.ExitCode));
                        }
                    }
            } catch (Exception ex) {
                logger.LogCritical(Resources.Error_AuthFailed, ex.Message);
            } finally {
                if (proc != null && !proc.HasExited)
                {
                    try {
                        proc.Kill();
                    } catch (Exception ex) when(!ex.IsCriticalException())
                    {
                    }
                }
            }

            profileDir = userDir;
            return(retval);
        }
示例#34
0
 public CommandPromptCommand(int id, IProcessServices ps) {
     _commandId = id;
     _ps = ps;
 }
        /// <summary>
        /// Gets the set of search paths by running the interpreter.
        /// </summary>
        /// <param name="interpreter">Path to the interpreter.</param>
        /// <param name="fs">File system services.</param>
        /// <param name="ps">Process services.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>A list of search paths for the interpreter.</returns>
        public static async Task <List <PythonLibraryPath> > GetSearchPathsFromInterpreterAsync(string interpreter, IFileSystem fs, IProcessServices ps, CancellationToken cancellationToken = default)
        {
            // sys.path will include the working directory, so we make an empty
            // path that we can filter out later
            var tempWorkingDir = IOPath.Combine(IOPath.GetTempPath(), IOPath.GetRandomFileName());

            fs.CreateDirectory(tempWorkingDir);
            if (!InstallPath.TryGetFile("get_search_paths.py", out var srcGetSearchPaths))
            {
                return(new List <PythonLibraryPath>());
            }
            var getSearchPaths = IOPath.Combine(tempWorkingDir, PathUtils.GetFileName(srcGetSearchPaths));

            File.Copy(srcGetSearchPaths, getSearchPaths);

            var startInfo = new ProcessStartInfo(
                interpreter,
                new[] { "-S", "-E", getSearchPaths }.AsQuotedArguments()
                )
            {
                WorkingDirectory       = tempWorkingDir,
                UseShellExecute        = false,
                ErrorDialog            = false,
                CreateNoWindow         = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true
            };

            try {
                var output = await ps.ExecuteAndCaptureOutputAsync(startInfo, cancellationToken);

                return(output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Select(s => {
                    try {
                        var p = Parse(s);

                        if (PathUtils.PathStartsWith(p.Path, tempWorkingDir))
                        {
                            return null;
                        }

                        return p;
                    } catch (ArgumentException) {
                        Debug.Fail("Invalid search path: " + (s ?? "<null>"));
                        return null;
                    } catch (FormatException) {
                        Debug.Fail("Invalid format for search path: " + s);
                        return null;
                    }
                }).Where(p => p != null).ToList());
            } finally {
                fs.DeleteDirectory(tempWorkingDir, true);
            }
        }
        /// <summary>
        /// Gets the set of search paths for the specified factory.
        /// </summary>
        public static async Task <IList <PythonLibraryPath> > GetSearchPathsAsync(InterpreterConfiguration config, IFileSystem fs, IProcessServices ps, CancellationToken cancellationToken = default)
        {
            for (int retries = 5; retries > 0; --retries)
            {
                try {
                    return(await GetSearchPathsFromInterpreterAsync(config.InterpreterPath, fs, ps, cancellationToken));
                } catch (InvalidOperationException) {
                    // Failed to get paths
                    break;
                } catch (Exception e) when(e is IOException || e is UnauthorizedAccessException)
                {
                    // Failed to get paths due to IO exception - sleep and then loop
                    Thread.Sleep(50);
                }
            }

            var ospy = PathUtils.FindFile(fs, config.LibraryPath, "os.py");
            var standardLibraryPath = !string.IsNullOrEmpty(ospy) ? IOPath.GetDirectoryName(ospy) : string.Empty;

            if (!string.IsNullOrEmpty(standardLibraryPath))
            {
                return(GetDefaultSearchPaths(fs, standardLibraryPath));
            }

            return(Array.Empty <PythonLibraryPath>());
        }
示例#37
0
 public WebBrowserServices(IVsWebBrowsingService wbs, IProcessServices ps, IRToolsSettings settings) {
     _wbs = wbs;
     _ps = ps;
     _settings = settings;
 }
 public OpenContainingFolderCommand(UnconfiguredProject unconfiguredProject, [Import(AllowDefault = true)] IProcessServices ps) {
     _unconfiguredProject = unconfiguredProject;
     _ps = ps ?? new ProcessServices();
 }
示例#39
0
 public OpenContainingFolderCommand(UnconfiguredProject unconfiguredProject, [Import(AllowDefault = true)] IProcessServices ps)
 {
     _unconfiguredProject = unconfiguredProject;
     _ps = ps ?? new ProcessServices();
 }
示例#40
0
 public ReportIssueCommand(ICoreServices services)
     : base(RGuidList.RCmdSetGuid, RPackageCommandId.icmdReportIssue) {
     _permissions = services.LoggingServices.Permissions;
     _pss = services.ProcessServices;
 }