Пример #1
0
        // Execute a command and wait for a response. No more interaction
        public override void ExecuteSyncCommand(string commandDescription, string commandText, out string commandOutput, int timeout, out int exitCode)
        {
            int    exit   = -1;
            string output = string.Empty;

            var settings = new DockerExecSettings(TransportSettings, commandText, runInShell: false, makeInteractive: false);
            var runner   = GetCommandRunner(settings, true);

            string dockerCommand = "{0} {1}".FormatInvariantWithArgs(settings.Command, settings.CommandArgs);
            string waitMessage   = StringResources.WaitingOp_ExecutingCommand.FormatCurrentCultureWithArgs(commandDescription);
            string errorMessage;

            VS.VSOperationWaiter.Wait(waitMessage, true, (cancellationToken) =>
            {
                if (OuterConnection != null)
                {
                    exit = OuterConnection.ExecuteCommand(dockerCommand, timeout, out output, out errorMessage);
                }
                else
                {
                    //local exec command
                    exit = ExecuteCommand(commandText, timeout, out output, out errorMessage);
                }
            });

            exitCode      = exit;
            commandOutput = output;
        }
Пример #2
0
        private ICommandRunner GetExecCommandRunner(string command, bool runInShell, bool makeInteractive)
        {
            var execSettings = new DockerExecSettings(_baseSettings, command, runInShell, makeInteractive);

            if (_outerConnection == null)
            {
                return(new LocalCommandRunner(execSettings));
            }
            else
            {
                return(new RemoteCommandRunner(execSettings.Command, execSettings.CommandArgs, _outerConnection));
            }
        }
Пример #3
0
        public override void BeginExecuteAsyncCommand(string commandText, bool runInShell, IDebugUnixShellCommandCallback callback, out IDebugUnixShellAsyncCommand asyncCommand)
        {
            if (IsClosed)
            {
                throw new ObjectDisposedException(nameof(PipeConnection));
            }

            if (runInShell)
            {
                AD7UnixAsyncShellCommand command = new AD7UnixAsyncShellCommand(CreateShellFromSettings(TransportSettings, OuterConnection), callback, closeShellOnComplete: true);
                command.Start(commandText);

                asyncCommand = command;
            }
            else
            {
                DockerExecSettings  settings = new DockerExecSettings(_containerName, commandText, true);
                AD7UnixAsyncCommand command  = new AD7UnixAsyncCommand(CreateShellFromSettings(settings, OuterConnection, true), callback, closeShellOnComplete: true);

                asyncCommand = command;
            }
        }
Пример #4
0
        private ICommandRunner GetExecCommandRunner(string commandText, bool handleRawOutput = false)
        {
            var execSettings = new DockerExecSettings(this.TransportSettings, commandText, handleRawOutput);

            return(GetCommandRunner(execSettings, handleRawOutput: handleRawOutput));
        }