コード例 #1
0
        ConfigStatus ParseParamsCmd(LaunchParams parameters,
                                    IDictionary <string, string> queryParams)
        {
            if (!queryParams.ContainsKey(QueryParamMapping.Cmd))
            {
                return(ConfigStatus.OkStatus());
            }

            string queryParamsCmd = queryParams[QueryParamMapping.Cmd];

            if (string.IsNullOrWhiteSpace(parameters.Cmd))
            {
                parameters.Cmd = queryParamsCmd;
                return(ConfigStatus.OkStatus());
            }

            // The cmd is valid only if the binary name is the same as in
            // the project output.
            string settingsBinaryName =
                parameters.Cmd.Split(' ').First(s => !string.IsNullOrEmpty(s));
            string queryBinaryName =
                queryParamsCmd.Split(' ').FirstOrDefault(s => !string.IsNullOrEmpty(s));

            if (queryBinaryName != settingsBinaryName)
            {
                return(ConfigStatus.ErrorStatus(
                           ErrorStrings.InvalidBinaryName(settingsBinaryName, queryBinaryName)));
            }

            parameters.Cmd = queryParamsCmd;

            return(ConfigStatus.OkStatus());
        }
コード例 #2
0
        List <ProcessListEntry> GetProcessList(IProcessListRequest request)
        {
            // TODO: Use single cancelable task for both actions
            try
            {
                var enableSshAction = _actionRecorder.CreateToolAction(ActionType.GameletEnableSsh);
                if (!_cancelableTaskFactory
                    .Create(TaskMessages.EnablingSSH,
                            async _ =>
                            await _sshManager.EnableSshAsync(Gamelet, enableSshAction))
                    .RunAndRecord(enableSshAction))
                {
                    return(new List <ProcessListEntry>());
                }
            }
            catch (Exception e) when(e is SshKeyException || e is CloudException)
            {
                Trace.WriteLine(e.ToString());
                _dialogUtil.ShowError(ErrorStrings.FailedToEnableSsh(e.Message), e.ToString());
                return(new List <ProcessListEntry>());
            }

            // TODO: Handle ProcessException
            var processListAction  = _actionRecorder.CreateToolAction(ActionType.ProcessList);
            var queryProcessesTask = _cancelableTaskFactory.Create(
                "Querying instance processes...",
                async() => await request.GetBySshAsync(new SshTarget(Gamelet)));

            queryProcessesTask.RunAndRecord(processListAction);
            return(queryProcessesTask.Result);
        }
コード例 #3
0
ファイル: GroupsCommand.cs プロジェクト: tonybaba2007/TeaTime
        public async Task <ICommandResult> RemoveGroup(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(Response(ErrorStrings.RemoveGroup_BadArguments(), ResponseType.User));
            }

            var context = await GetContextAsync().ConfigureAwait(false);

            var group = await _mediator.Send(new GetRoomItemGroupByNameQuery(context.Room.Id, context.User.Id, name)).ConfigureAwait(false);

            if (group == null)
            {
                return(Response(ErrorStrings.RemoveGroup_GroupInvalidName(name), ResponseType.User));
            }

            var command = new DeleteRoomItemGroupCommand(
                groupId: group.Id,
                userId: context.User.Id
                );

            await _mediator.Send(command).ConfigureAwait(false);

            return(Response(ResponseStrings.GroupRemoved(name), ResponseType.User));
        }
コード例 #4
0
        bool PromptToDeleteLaunch(GgpGrpc.Models.GameLaunch currentGameLaunch,
                                  List <Gamelet> gamelets, Gamelet selectedGamelet,
                                  ActionRecorder actionRecorder,
                                  string testAccount, string devAccount)
        {
            if (currentGameLaunch.GameLaunchState == GameLaunchState.IncompleteLaunch)
            {
                return(true);
            }

            bool   thisInstance = selectedGamelet.Name == currentGameLaunch.GameletName;
            string instanceName = gamelets
                                  .SingleOrDefault(g => g.Name == currentGameLaunch.GameletName)?.DisplayName;
            bool okToStop = actionRecorder.RecordUserAction(ActionType.GameLaunchStopPrompt,
                                                            () => _dialogUtil.ShowYesNo(
                                                                ErrorStrings.LaunchExistsDialogText(
                                                                    thisInstance, instanceName,
                                                                    testAccount, devAccount),
                                                                ErrorStrings.StopRunningGame));

            if (!okToStop)
            {
                // Developer opted to not stop the existing launch.
                // Launch can not proceed.
                return(false);
            }

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Check that the specified remote process's binary has a valid build id. Log messages and
        /// record metrics to indicate the result of the checks.
        /// </summary>
        /// <param name="pid">Process ID of the remote process that we will check</param>
        /// <param name="target">The machine that should have a valid remote binary</param>
        public async Task CheckRemoteBinaryOnAttachAsync(uint pid, SshTarget target,
                                                         IAction action)
        {
            var remoteTargetPath = string.Format(PID_EXE_PATH_TEMPLATE, pid);

            try
            {
                var dataRecorder =
                    new DataRecorder(action, DebugPreflightCheckData.Types.CheckType.AttachOnly);

                BuildId remoteBuildId;
                try
                {
                    remoteBuildId = await binaryFileUtil.ReadBuildIdAsync(remoteTargetPath,
                                                                          target);
                }
                catch (BinaryFileUtilException e) when(dataRecorder.RemoteBuildIdError(e))
                {
                    Debug.Fail("Exception should never be caught");
                    throw;
                }

                // Log the remote Build ID for debugging purposes.
                dataRecorder.ValidRemoveBuildId();
                Trace.WriteLine("Remote build ID: " + remoteBuildId.ToString());
            }
            catch (BinaryFileUtilException e)
            {
                Trace.WriteLine($"Failed to read build ID for '{remoteTargetPath}' " +
                                $"on '{target.GetString()}': " + e.ToString());
                throw new PreflightBinaryCheckerException(
                          ErrorStrings.FailedToCheckRemoteBuildIdWithExplanation(e.Message), e);
            }
        }
コード例 #6
0
        public async Task <ICommandResult> RemoveOption(string groupName, string optionName)
        {
            if (string.IsNullOrWhiteSpace(groupName) || string.IsNullOrWhiteSpace(optionName))
            {
                return(Response(ErrorStrings.RemoveOption_BadArguments(), ResponseType.User));
            }

            var context = await GetContextAsync().ConfigureAwait(false);

            var group = await _mediator.Send(new GetRoomItemGroupByNameQuery(
                                                 roomId : context.Room.Id,
                                                 userId : context.User.Id,
                                                 name : groupName)).ConfigureAwait(false);

            if (group == null)
            {
                return(Response(ErrorStrings.RemoveOption_GroupInvalidName(groupName), ResponseType.User));
            }

            var option = group.Options.FirstOrDefault(o => o.Name.Equals(optionName));

            if (option == null)
            {
                return(Response(ErrorStrings.RemoveOption_UnknownOption(optionName), ResponseType.User));
            }

            var command = new DeleteOptionCommand(option.Id, context.User.Id);

            await _mediator.Send(command).ConfigureAwait(false);

            return(Response(ResponseStrings.OptionRemoved(optionName, groupName), ResponseType.User));
        }
コード例 #7
0
        public async Task <ICommandResult> AddOption(string groupName, string optionName)
        {
            if (string.IsNullOrWhiteSpace(groupName) || string.IsNullOrWhiteSpace(optionName))
            {
                return(Response(ErrorStrings.AddOption_BadArguments(), ResponseType.User));
            }

            var context = await GetContextAsync().ConfigureAwait(false);

            var group = await _mediator.Send(new GetRoomItemGroupByNameQuery(
                                                 roomId : context.Room.Id,
                                                 userId : context.User.Id,
                                                 name : groupName)).ConfigureAwait(false);

            if (group == null)
            {
                return(Response(ErrorStrings.AddOption_GroupInvalidName(groupName), ResponseType.User));
            }

            var command =
                new CreateOptionCommand(
                    id: await _idGenerator.GenerateAsync().ConfigureAwait(false),
                    userId: context.User.Id,
                    groupId: group.Id,
                    name: optionName);

            await _mediator.Send(command).ConfigureAwait(false);

            return(Response(ResponseStrings.OptionAddedToGroup(optionName, group.Name), ResponseType.User));
        }
コード例 #8
0
        public bool ValidAddHallTable(string row, string seat)
        {
            try
            {
                if (row == string.Empty)
                {
                    ErrorString += "-- Поле количество рядов не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (seat == string.Empty)
                {
                    ErrorString += "-- Поле количество мест в ряду не должно быть пустым!\n";
                    ValidKey     = false;
                }


                if (ValidKey)
                {
                    return(ValidKey);
                }
                else
                {
                    ErrorStrings.Add(ErrorString);
                    return(ValidKey);
                }
            }
            finally
            {
                ValidKey    = true;
                ErrorString = "--- Введите корректные значения ---\n" +
                              "-----------------------------------------\n";
            }
        }
コード例 #9
0
ファイル: SlackService.cs プロジェクト: tonybaba2007/TeaTime
        private async Task JoinRunAsync(long userId, long roomId, string optionName, CallbackData callbackData)
        {
            var run = await _mediator.Send(new GetCurrentRunQuery(roomId, userId)).ConfigureAwait(false);

            if (run == null)
            {
                throw new SlackTeaTimeException(ErrorStrings.JoinRun_RunNotStarted());
            }

            var group = await _mediator.Send(new GetRoomItemGroupQuery(roomId : run.RoomId, userId : userId, groupId : run.GroupId)).ConfigureAwait(false);

            if (group == null)
            {
                _logger.LogWarning("Failed to find group {GroupId} in room {RoomId} for run {RunId}", run.GroupId, roomId, run.Id);
                throw new SlackTeaTimeException(ErrorStrings.General());
            }

            var option = group.Options.FirstOrDefault(o => o.Name.Equals(optionName, StringComparison.OrdinalIgnoreCase));

            if (option == null)
            {
                throw new SlackTeaTimeException(ErrorStrings.OptionUnknown());
            }

            await JoinRunInternalAsync(userId, run, option.Id, callbackData).ConfigureAwait(false);
        }
コード例 #10
0
        ConfigStatus AddBoolEnvironmentVariable(LaunchGameRequest launchRequest,
                                                IDictionary <string, string> queryParams,
                                                string variableName, string queryParamName)
        {
            if (!queryParams.ContainsKey(queryParamName) ||
                launchRequest.EnvironmentVariablePairs.ContainsKey(variableName))
            {
                return(ConfigStatus.OkStatus());
            }

            if (!bool.TryParse(queryParams[queryParamName], out bool isTrue))
            {
                if (!int.TryParse(queryParams[queryParamName], out int intVal) || intVal < 0 ||
                    intVal > 1)
                {
                    return(ConfigStatus.WarningStatus(ErrorStrings.InvalidQueryParameterType(
                                                          queryParamName,
                                                          queryParams[queryParamName],
                                                          typeof(bool))));
                }

                isTrue = intVal == 1;
            }

            if (isTrue)
            {
                launchRequest.EnvironmentVariablePairs.Add(variableName, "1");
            }

            return(ConfigStatus.OkStatus());
        }
コード例 #11
0
        public async Task <ICommandResult> Start(string group = "tea")
        {
            var context = await GetContextAsync().ConfigureAwait(false);

            var roomItemGroup = await _mediator.Send(new GetRoomItemGroupByNameQuery(roomId : context.Room.Id, userId : context.User.Id, name : group)).ConfigureAwait(false);

            if (roomItemGroup == null)
            {
                return(Response(ErrorStrings.StartRun_GroupInvalidName(group), ResponseType.User));
            }

            if (!roomItemGroup.Options.Any())
            {
                return(Response(ErrorStrings.StartRun_GroupNoOptions(roomItemGroup.Name), ResponseType.User));
            }

            var command = new StartRunCommand(
                id: await _idGenerator.GenerateAsync().ConfigureAwait(false),
                userId: context.User.Id,
                roomId: context.Room.Id,
                roomGroupId: roomItemGroup.Id,
                startTime: _clock.UtcNow());

            await _mediator.Send(command).ConfigureAwait(false);

            return(Response(new SlashCommandResponse
            {
                Text = ResponseStrings.RunStarted(context.Command.UserId, roomItemGroup.Name),
                Type = ResponseType.Channel,
                Attachments = AttachmentBuilder.BuildOptions(roomItemGroup.Options)
            }));
        }
コード例 #12
0
        public async Task <ICommandResult> IllMake()
        {
            var context = await GetContextAsync().ConfigureAwait(false);

            var run = await _mediator.Send(new GetCurrentRunQuery(context.Room.Id, context.User.Id)).ConfigureAwait(false);

            if (run == null)
            {
                return(Response(ErrorStrings.IllMake_RunNotStarted(), ResponseType.User));
            }

            var command = new Common.Features.IllMake.Commands.IllMakeCommand(
                id: await _idGenerator.GenerateAsync().ConfigureAwait(false),
                runId: run.Id,
                userId: context.User.Id
                );

            await _mediator.Send(command).ConfigureAwait(false);

            return(Response(new SlashCommandResponse
            {
                Text = ResponseStrings.IllMake(context.Command.UserId),
                Type = ResponseType.Channel
            }));
        }
コード例 #13
0
        /// <summary>
        ///     Changes the file that is being read, setting up the new reader
        /// </summary>
        /// <param name="newFile"></param>
        private void ChangeFile(string newFile)
        {
            ErrorStrings.Clear();

            // Dispose of the old reader as needed
            try
            {
                if (Reader != null)
                {
                    Reader.Dispose();
                }
            } catch { }
            Reader = null;

            // Create the new reader
            try
            {
                Reader = File.OpenText(newFile);
            }
            catch (Exception ex)
            {
                ErrorStrings.Add(ex.Message);
            }

            InvokeOnErrorStringsChanged();
        }
コード例 #14
0
        public void CheckLocalAndRemoteBinaryFailsMismatch()
        {
            fileSystem.AddDirectory(searchPaths[0]);
            fileSystem.AddFile(localPaths[0], new MockFileData(""));
            binaryFileUtil.ReadBuildIdAsync(localPaths[0]).Returns(Task.FromResult(validBuildId2));

            binaryFileUtil.ReadBuildIdAsync(remoteTargetPath, target).Returns(
                Task.FromResult(validBuildId));

            Exception ex = Assert.ThrowsAsync <PreflightBinaryCheckerException>(async() =>
                                                                                await action.RecordAsync(checker.CheckLocalAndRemoteBinaryOnLaunchAsync(
                                                                                                             searchPaths, executable, target, remoteTargetPath, action)));

            Assert.AreEqual(ErrorStrings.UnableToFindExecutableMatchingRemoteBinary(executable,
                                                                                    remoteTargetPath), ex.Message);

            metrics.Received().RecordEvent(
                DeveloperEventType.Types.Type.VsiDebugPreflightBinaryCheck,
                Arg.Is <DeveloperLogEvent>(m =>
                                           m.StatusCode == DeveloperEventStatus.Types.Code.InvalidConfiguration &&
                                           m.DebugPreflightCheckData.CheckType ==
                                           DebugPreflightCheckData.Types.CheckType.RunAndAttach &&
                                           m.DebugPreflightCheckData.RemoteBuildIdCheckResult ==
                                           DebugPreflightCheckData.Types.RemoteBuildIdCheckResult
                                           .ValidRemoteBuildId &&
                                           m.DebugPreflightCheckData.LocalBinarySearchResult ==
                                           DebugPreflightCheckData.Types.LocalBinarySearchResult.BinaryMismatch));
        }
コード例 #15
0
        public void DeployGameExecutablePopulatesActionEventOnFailureInDeployment(
            [Values(DeployOnLaunchSetting.DELTA, DeployOnLaunchSetting.ALWAYS)]
            DeployOnLaunchSetting value)
        {
            string        localPath = GetLocalPath();
            IAsyncProject project   = GetProjectWithLocalPathAndDeployMode(localPath, value);

            (SshTarget target, IAction action, ICancelable cancelable) = GetDeploymentArguments();
            (IRemoteFile file, _, IRemoteDeploy deploy, _)             = GetTestObjects();
            file
            .SyncAsync(Arg.Any <SshTarget>(), Arg.Any <string>(), Arg.Any <string>(),
                       Arg.Any <ICancelable>(), Arg.Any <bool>())
            .Returns <Task>(_ => throw new ProcessException(_rsyncFailed));

            var error = Assert.ThrowsAsync <DeployException>(
                async() =>
                await deploy.DeployGameExecutableAsync(
                    project, target, cancelable, action));

            Assert.Multiple(() =>
            {
                string expectedError = ErrorStrings.FailedToDeployExecutable(_rsyncFailed);
                Assert.That(error.Message, Is.EqualTo(expectedError));
                CopyBinaryData actionEvent = action.GetEvent().CopyExecutable;
                Assert.NotNull(actionEvent);
                Assert.NotNull(actionEvent.CopyBinaryBytes);
                Assert.IsTrue(actionEvent.CopyAttempted);
                Assert.That(actionEvent.CopyExitCode, Is.EqualTo(-1));
                Assert.IsNull(actionEvent.SshChmodExitCode);
            });
        }
コード例 #16
0
        public void CheckLocalAndRemoteBinaryFailsInvalidRemoteBuildId()
        {
            fileSystem.AddDirectory(searchPaths[0]);
            fileSystem.AddFile(localPaths[0], new MockFileData(""));
            binaryFileUtil.ReadBuildIdAsync(localPaths[0]).Returns(Task.FromResult(validBuildId));

            binaryFileUtil.ReadBuildIdAsync(remoteTargetPath, target).Returns(
                Task.FromException <BuildId>(new InvalidBuildIdException("test")));

            Exception ex = Assert.ThrowsAsync <PreflightBinaryCheckerException>(async() =>
                                                                                await action.RecordAsync(checker.CheckLocalAndRemoteBinaryOnLaunchAsync(
                                                                                                             searchPaths, executable, target, remoteTargetPath, action)));

            Assert.IsInstanceOf <BinaryFileUtilException>(ex.InnerException);
            Assert.AreEqual(ErrorStrings.FailedToCheckRemoteBuildIdWithExplanation(
                                ex.InnerException.Message), ex.Message);

            metrics.Received().RecordEvent(
                DeveloperEventType.Types.Type.VsiDebugPreflightBinaryCheck,
                Arg.Is <DeveloperLogEvent>(m =>
                                           m.StatusCode == DeveloperEventStatus.Types.Code.InvalidConfiguration &&
                                           m.DebugPreflightCheckData.CheckType ==
                                           DebugPreflightCheckData.Types.CheckType.RunAndAttach &&
                                           m.DebugPreflightCheckData.RemoteBuildIdCheckResult ==
                                           DebugPreflightCheckData.Types.RemoteBuildIdCheckResult
                                           .InvalidRemoteBuildId));
        }
コード例 #17
0
 public bool ValidDeleteTicketsTable(string id)
 {
     try
     {
         if (id == string.Empty)
         {
             ErrorString += "-- Выберете строку, которую нужно удалить!\n";
             ValidKey     = false;
         }
         if (ValidKey)
         {
             return(ValidKey);
         }
         else
         {
             ErrorStrings.Add(ErrorString);
             return(ValidKey);
         }
     }
     finally
     {
         ValidKey    = true;
         ErrorString = "--- Введите корректные значения ---\n" +
                       "-----------------------------------------\n";
     }
 }
コード例 #18
0
ファイル: SlackService.cs プロジェクト: tonybaba2007/TeaTime
        private async Task JoinRunInternalAsync(long userId, Run run, long optionId, CallbackData callbackData)
        {
            BaseCommand command;

            if (run.Ended)
            {
                throw new SlackTeaTimeException(ErrorStrings.JoinRun_RunEnded());
            }

            //check if we need to join or update
            var existingOrder = await _mediator.Send(new GetUserOrderQuery(run.Id, userId)).ConfigureAwait(false);

            if (existingOrder == null)
            {
                command = new CreateOrderCommand(
                    id: await _idGenerator.GenerateAsync().ConfigureAwait(false),
                    runId: run.Id,
                    userId: userId,
                    optionId: optionId);
            }
            else
            {
                //we need to update the existing order
                command = new UpdateOrderOptionCommand(existingOrder.Id, userId, optionId);
            }

            command.AddCallbackState(callbackData);

            await _mediator.Send(command).ConfigureAwait(false);
        }
コード例 #19
0
        public void CheckRemoteBinaryFailsToRunRemoteCommand()
        {
            binaryFileUtil.ReadBuildIdAsync(remoteTargetPath, target).Returns(
                Task.FromException <BuildId>(new BinaryFileUtilException("test",
                                                                         new ProcessException("inner"))));

            Exception ex = Assert.ThrowsAsync <PreflightBinaryCheckerException>(async() =>
                                                                                await action.RecordAsync(checker.CheckRemoteBinaryOnAttachAsync(remoteTargetPid,
                                                                                                                                                target, action)));

            Assert.IsInstanceOf <BinaryFileUtilException>(ex.InnerException);
            Assert.AreEqual(ErrorStrings.FailedToCheckRemoteBuildIdWithExplanation(
                                ex.InnerException.Message), ex.Message);

            metrics.Received().RecordEvent(
                DeveloperEventType.Types.Type.VsiDebugPreflightBinaryCheck,
                Arg.Is <DeveloperLogEvent>(m =>
                                           m.StatusCode ==
                                           DeveloperEventStatus.Types.Code.ExternalToolUnavailable &&
                                           m.DebugPreflightCheckData.CheckType ==
                                           DebugPreflightCheckData.Types.CheckType.AttachOnly &&
                                           m.DebugPreflightCheckData.RemoteBuildIdCheckResult ==
                                           DebugPreflightCheckData.Types.RemoteBuildIdCheckResult
                                           .RemoteCommandError));
        }
コード例 #20
0
        ConfigStatus ParseLaunchRequestVulkanDriverVariant(LaunchGameRequest launchRequest,
                                                           IDictionary <string, string> queryParams)
        {
            ConfigStatus status = ConfigStatus.OkStatus();

            if (queryParams.ContainsKey(QueryParamMapping.VulkanDriverVariant))
            {
                string driverVariant = "GGP_DEV_VK_DRIVER_VARIANT";
                if (!launchRequest.EnvironmentVariablePairs.ContainsKey(driverVariant))
                {
                    var allowedValues = new[] { "opt", "optprintasserts", "dbgtrapasserts" };
                    if (!allowedValues.Contains(queryParams[QueryParamMapping.VulkanDriverVariant]
                                                .ToLower()))
                    {
                        status.AppendWarning(ErrorStrings.InvalidEnumValue(
                                                 QueryParamMapping.VulkanDriverVariant,
                                                 queryParams[QueryParamMapping.VulkanDriverVariant],
                                                 allowedValues));
                    }
                    else
                    {
                        launchRequest.EnvironmentVariablePairs.Add(
                            driverVariant,
                            queryParams[QueryParamMapping.VulkanDriverVariant].ToLower());
                    }
                }
            }

            return(status);
        }
コード例 #21
0
        ConfigStatus SetEnumProperty <T>(
            T assignObject, PropertyInfo property, string paramName, string value)
        {
            Type propertyType   = property.PropertyType;
            var  expectedValues = new List <string>();

            foreach (string fieldName in Enum.GetNames(propertyType))
            {
                FieldInfo fieldInfo = propertyType.GetField(fieldName);
                var       attr      = (MapValueAttribute)fieldInfo
                                      .GetCustomAttributes(typeof(MapValueAttribute), false).SingleOrDefault();
                if (attr == null)
                {
                    continue;
                }

                if (value.ToLower() == attr.QueryParameterValue.ToLower())
                {
                    property.SetValue(assignObject, Enum.Parse(propertyType, fieldName));
                    return(ConfigStatus.OkStatus());
                }

                expectedValues.Add(attr.QueryParameterValue);
            }

            return(ConfigStatus.WarningStatus(
                       ErrorStrings.InvalidEnumValue(paramName, value, expectedValues)));
        }
コード例 #22
0
        public void TestAttachToGameFail_AnotherTracer()
        {
            string parentPid  = "1234";
            string tracerPid  = "9876";
            string tracerName = "gdb";

            var launcherFactory = CreateLauncherFactory(false);
            var launcher        = launcherFactory.Create(_debugEngine, LaunchOption.AttachToGame, "",
                                                         _gameBinary, _gameBinary, _gameLaunch);

            _debuggerFactory.SetTargetAttachError("Operation not permitted");
            _platformFactory.AddCommandOutput($"cat /proc/{_pid}/status",
                                              "Name:\tgame\n" + $"Pid:\t{_pid}\n" +
                                              $"PPid:\t{parentPid}\n" +
                                              $"TracerPid:\t{tracerPid}\n" + "FDSize:\t256\n");
            _platformFactory.AddCommandOutput($"cat /proc/{tracerPid}/comm", tracerName);

            AttachException e =
                Assert.ThrowsAsync <AttachException>(async() => await LaunchAsync(launcher));

            Assert.That(e.Message,
                        Is.EqualTo(
                            ErrorStrings
                            .FailedToAttachToProcessOtherTracer(tracerName, tracerPid)));
            CheckLldbListenerStops();
        }
コード例 #23
0
        void RefreshCoreList()
        {
            if (_instance == null)
            {
                return;
            }

            Cursor = System.Windows.Input.Cursors.Wait;
            try
            {
                var queryTaskTitle = "Querying instance crash dumps...";
                var queryTask      = _cancelableTaskFactory.Create(
                    queryTaskTitle,
                    async() => await _coreListRequest.GetCoreListAsync(new SshTarget(_instance)));

                // Ignore cancelation, and accept the empty result.
                queryTask.RunAndRecord(_actionRecorder, ActionType.CrashDumpList);
                CoreList.ItemsSource = queryTask.Result;
            }
            catch (ProcessException e)
            {
                Trace.WriteLine($"Unable to query instance crash dumps: {e}");
                GameletMessageTextBox.Text = ErrorStrings.ErrorQueryingCoreFiles(e.Message);
                CoreList.ItemsSource       = new List <CoreListEntry>();
            }
            finally
            {
                Cursor = null;
            }
        }
コード例 #24
0
        public async Task <ICommandResult> End()
        {
            var context = await GetContextAsync().ConfigureAwait(false);

            var run = await _mediator.Send(new GetCurrentRunQuery(context.Room.Id, context.User.Id)).ConfigureAwait(false);

            if (run == null)
            {
                return(Response(ErrorStrings.EndRun_RunNotStarted(), ResponseType.User));
            }

            var orders = await _mediator.Send(new GetRunOrdersQuery(run.Id, context.User.Id)).ConfigureAwait(false);

            var command = new EndRunCommand(
                runId: run.Id,
                roomId: context.Room.Id,
                userId: context.User.Id,
                orders: orders
                );

            command.AddCallbackState(context.Command.ToCallbackData());

            await _mediator.Send(command).ConfigureAwait(false);

            return(Response(null, ResponseType.Channel));
        }
コード例 #25
0
        public void CheckLocalAndRemoteBinaryFailsReadLocal()
        {
            fileSystem.AddDirectory(searchPaths[0]);
            fileSystem.AddFile(localPaths[0], new MockFileData(""));
            binaryFileUtil.ReadBuildIdAsync(localPaths[0])
            .Returns(Task.FromException <BuildId>(new BinaryFileUtilException("test")));

            binaryFileUtil.ReadBuildIdAsync(remoteTargetPath, target).Returns(
                Task.FromResult(validBuildId));

            Exception ex = Assert.ThrowsAsync <PreflightBinaryCheckerException>(async() =>
                                                                                await action.RecordAsync(checker.CheckLocalAndRemoteBinaryOnLaunchAsync(
                                                                                                             searchPaths, executable, target, remoteTargetPath, action)));

            Assert.AreEqual(ErrorStrings.UnableToFindExecutableMatchingRemoteBinary(executable,
                                                                                    remoteTargetPath), ex.Message);


            // Note that the local build id failure results in an invalid configuration error
            // because we don't propagate the original BinaryFileUtilException but rather throw
            // our own ConfigurationException. (We may have failed on more than one file.)
            metrics.Received().RecordEvent(
                DeveloperEventType.Types.Type.VsiDebugPreflightBinaryCheck,
                Arg.Is <DeveloperLogEvent>(m =>
                                           m.StatusCode == DeveloperEventStatus.Types.Code.InvalidConfiguration &&
                                           m.DebugPreflightCheckData.CheckType ==
                                           DebugPreflightCheckData.Types.CheckType.RunAndAttach &&
                                           m.DebugPreflightCheckData.RemoteBuildIdCheckResult ==
                                           DebugPreflightCheckData.Types.RemoteBuildIdCheckResult
                                           .ValidRemoteBuildId &&
                                           m.DebugPreflightCheckData.LocalBinarySearchResult ==
                                           DebugPreflightCheckData.Types.LocalBinarySearchResult.BinaryMismatch));
        }
コード例 #26
0
 public string[] Get(int number)
 {
     string[] errors = new string[number];
     for (int errorNumber = 0; errorNumber < number; errorNumber++)
     {
         errors[errorNumber] = ErrorStrings.FullError();
     }
     return(errors);
 }
コード例 #27
0
        public bool ValidAddStaffTable(string surname, string name, string patronymic, string position, string birthdate, string entrydate)
        {
            try
            {
                if (surname == string.Empty)
                {
                    ErrorString += "-- Поле фамилия не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (name == string.Empty)
                {
                    ErrorString += "-- Поле имя не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (patronymic == string.Empty)
                {
                    ErrorString += "-- Поле отчество не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (position == string.Empty)
                {
                    ErrorString += "-- Поле должность не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (birthdate.Length < 10)
                {
                    ErrorString += "-- Поле даты не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (entrydate.Length < 10)
                {
                    ErrorString += "-- Поле жанр не должно быть пустым!\n";
                    ValidKey     = false;
                }

                if (ValidKey)
                {
                    return(ValidKey);
                }
                else
                {
                    ErrorStrings.Add(ErrorString);
                    return(ValidKey);
                }
            }
            finally
            {
                ValidKey    = true;
                ErrorString = "--- Введите корректные значения ---\n" +
                              "-----------------------------------------\n";
            }
        }
コード例 #28
0
        public static uint GetErrorHash(ErrorStrings errorString)
        {
            if (!ErrorStringsCache.TryGetValue(errorString, out var result))
            {
                result = GenerateHashC(errorString.ToString());
                ErrorStringsCache.TryAdd(errorString, result);
            }

            return(result);
        }
コード例 #29
0
ファイル: SSHKey.cs プロジェクト: googlestadia/vsi-lldb
        public async Task <SshKey> LoadOrCreateAsync()
        {
            var keyDir = Path.GetDirectoryName(keyPath);

            try
            {
                Directory.CreateDirectory(keyDir);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to create keys directory: " + e.ToString());
                throw new SshKeyException(ErrorStrings.FailedToCreateSshKeysDirectory(e.Message));
            }

            if (!File.Exists(keyPath))
            {
                var startInfo = new ProcessStartInfo
                {
                    FileName = Path.Combine(SDKUtil.GetSshPath(),
                                            YetiConstants.SshKeygenWinExecutable),
                    Arguments = "-f \"" + keyPath + "\" -t rsa -N \"\"",
                };
                using (var process = managedProcessFactory.Create(startInfo))
                {
                    try
                    {
                        int code = await process.RunToExitAsync();

                        if (code != 0)
                        {
                            Trace.WriteLine("Key generation returned code: " + code);
                            throw new SshKeyException(ErrorStrings.SshKeyGenerationFailed(
                                                          YetiConstants.SshKeygenWinExecutable, code));
                        }
                    }
                    catch (ProcessException e)
                    {
                        Trace.WriteLine("Key generation threw: " + e.ToString());
                        throw new SshKeyException(
                                  ErrorStrings.FailedToRunSshKeyGeneration(e.Message));
                    }
                }
            }
            try
            {
                return(new SshKey {
                    PublicKey = File.ReadAllText(keyPath + ".pub")
                });
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to read key file: " + e.ToString());
                throw new SshKeyException(ErrorStrings.FailedToReadSshKeyFile(e.Message));
            }
        }
コード例 #30
0
 ConfigStatus SetUlongProperty <T>(
     T assignObject, PropertyInfo property, string paramName, string value)
 {
     if (!ulong.TryParse(value, out ulong ulongValue))
     {
         return(ConfigStatus.WarningStatus(
                    ErrorStrings.InvalidQueryParameterType(paramName, value, typeof(ulong))));
     }
     property.SetValue(assignObject, ulongValue);
     return(ConfigStatus.OkStatus());
 }