Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            App.InitExceptionAndLogging();
            string runningProcName;

            if (ProcessUtils.IsAnyInstallerProcesRunning(out runningProcName) && !string.IsNullOrEmpty(runningProcName))
            {
                Logger.Info(runningProcName + " process is running. Exiting BlueStacks LogCollector");
                Environment.Exit(-1);
            }
            App.PrintAndPraseArgs(args);
            App.SetVmPropertiesOrExit(App.sOpt.Vmname);
            App app = new App();

            app.Startup += (StartupEventHandler)((sender, e) => App.Application_Startup(sender, e, args));
            app.Exit    += new ExitEventHandler(App.Application_Exit);
            RegistryManager.ClientThemeName = RegistryManager.Instance.GetClientThemeNameFromRegistry();
            app.Run();
        }
Ejemplo n.º 2
0
        public bool IsSenderMatching(string strSender)
        {
            try
            {
                IWebElement senderElement = _wait.Until(ExpectedConditions.ElementExists(By.XPath($"//h3//span[@email='{strSender}']")));

                if (null != senderElement)
                {
                    Console.WriteLine($"senderElement.GetAttribute('email'): {senderElement.GetAttribute("email")}, strSender: {strSender}");
                    return(senderElement.GetAttribute("email").Equals(strSender));
                }
            }
            catch (WebDriverTimeoutException timeout)
            {
                ProcessUtils.ConsoleLog(timeout.Message);
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public ProcessStartInfo GetStartInfo(Selections selections, params string[] arguments)
        {
            #region Sanity checks
            if (selections == null)
            {
                throw new ArgumentNullException(nameof(selections));
            }
            if (arguments == null)
            {
                throw new ArgumentNullException(nameof(arguments));
            }
            #endregion

            if (string.IsNullOrEmpty(selections.Command))
            {
                throw new ExecutorException("The Selections document does not specify a start command.");
            }
            if (selections.Implementations.Count == 0)
            {
                throw new ExecutorException("The Selections document does not list any implementations.");
            }
            Selections = selections;

            ProcessUtils.SanitizeEnvironmentVariables();

            try
            {
                var startInfo   = BuildStartInfoWithBindings();
                var commandLine = GetCommandLine(GetMainImplementation(), Selections.Command, startInfo);
                PrependWrapper(commandLine);
                AppendUserArgs(arguments, commandLine);
                ProcessRunEnvBindings(startInfo);
                ApplyCommandLine(commandLine, startInfo);
                return(startInfo);
            }
            #region Error handling
            catch (KeyNotFoundException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new ExecutorException(ex.Message);
            }
            #endregion
        }
Ejemplo n.º 4
0
        private async void btnLaunchAndroidCommander_Click(object sender, RoutedEventArgs e)
        {
            if (VmManager.Instance.RunningGroupIndex == -1)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            List <Task> tasks = new List <Task>();

            string[] devices = ProcessUtils.GetAttachedDevices();

            foreach (var device in devices)
            {
                tasks.Add(LaunchAndroidCommanderAsync(device));
            }

            await Task.WhenAll(tasks);
        }
 public void ClickComposeButton()
 {
     try
     {
         if (null != _wait.Until(ExpectedConditions.ElementToBeClickable(_composeButton)))
         {
             _composeButton.Click();
             _wait.Until(ExpectedConditions.TextToBePresentInElement(_newMessageDialog, "New Message"));
         }
         else
         {
             ProcessUtils.ConsoleLog("ERROR: COMPOSE Button Not Available");
         }
     }
     catch (WebDriverTimeoutException timeout)
     {
         ProcessUtils.ConsoleLog(timeout.Message);
     }
 }
Ejemplo n.º 6
0
        private async void btnLaunchWhatsApp_Click(object sender, RoutedEventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo));
                return;
            }

            string          packagename = "com.whatsapp";
            List <Phonenum> listPhon    = new PhonenumBLL().SelectPhoneNumber();

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];

                //获取imei、androidid值
                di = new System.Collections.Generic.Dictionary <int, Wx.Qunkong360.Wpf.Abstract.VmModel>(VmManager.Instance._vmModels);

                if (vmIndex != -1)
                {
                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                }
                #region 获取登录信息
                List <Simulators> list = SimulatorsBLL.GetSimulatorsList();
                int listcount          = list.Count;
                if (listPhon.Count != 0)
                {
                    AppOptViewModel.simulators.Add(new Simulators()
                    {
                        id        = i + listcount + 1,
                        phonenum  = listPhon[i].PhoneNum.Substring(1),
                        imei      = di[i].Imei,
                        androidid = di[i].AndroidId,
                        created   = listPhon[i].Created
                    });
                }
                #endregion
            }

            string installNewestAppLog = await AppUpgradeHelper.Instance.InstallNewestApp();

            LogUtils.Information(installNewestAppLog);
        }
 public void SetMessageBody(string strMessageBody)
 {
     try
     {
         if (null != _wait.Until(ExpectedConditions.ElementToBeClickable(_messageBody)))
         {
             _messageBody.Clear();
             _messageBody.SendKeys(strMessageBody);
         }
         else
         {
             ProcessUtils.ConsoleLog("ERROR: New Message Body Field Not Found");
         }
     }
     catch (WebDriverTimeoutException timeout)
     {
         ProcessUtils.ConsoleLog(timeout.Message);
     }
 }
Ejemplo n.º 8
0
        public void ClickOnViewMessageLink()
        {
            try
            {
                if (null != _wait.Until(ExpectedConditions.ElementToBeClickable(_viewMessageLink)))
                {
                    _actionsBuilder.MoveToElement(_viewMessageLink)
                    .Click()
                    .Build()
                    .Perform();

                    _browserDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
                }
            }
            catch (WebDriverTimeoutException timeout)
            {
                ProcessUtils.ConsoleLog(timeout.Message);
            }
        }
Ejemplo n.º 9
0
 private void linkLabelDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (InterfaceUri.IsFake)
     {
         return;
     }
     try
     {
         ProcessUtils.Start(InterfaceUri.OriginalString);
     }
     #region Error handling
     catch (OperationCanceledException)
     {}
     catch (IOException ex)
     {
         Msg.Inform(this, ex.Message, MsgSeverity.Error);
     }
     #endregion
 }
 private void SetReceiverField(string strReceiver)
 {
     try
     {
         if (null != _wait.Until(ExpectedConditions.ElementToBeClickable(_receiverField)))
         {
             _receiverField.Clear();
             _receiverField.SendKeys(strReceiver);
         }
         else
         {
             ProcessUtils.ConsoleLog("ERROR: New Message Receiver Field Not Found");
         }
     }
     catch (WebDriverTimeoutException timeout)
     {
         ProcessUtils.ConsoleLog(timeout.Message);
     }
 }
Ejemplo n.º 11
0
        public static async void ToggleMouseCursorVisibility()
        {
            var process = ProcessUtils.Start("Resources\\HideCursor.exe");


            /*if (MouseCursorIsHidden)
             * {
             *  NativeMethods.SetSystemCursor(_hCursorOriginal, OcrSystemCursorType.OcrNormal);
             *  NativeMethods.DestroyIcon(_hCursorOriginal);
             *  _hCursorOriginal = IntPtr.Zero;
             *
             *  MouseCursorIsHidden = false;
             * }
             * else
             * {
             * var blankPtr = NativeMethods.LoadCursorFromFile(Path.Combine(Directory.GetCurrentDirectory(), "blank.cur"));
             * NativeMethods.SetSystemCursor(blankPtr, OcrSystemCursorType.OcrNormal);
             * }*/
        }
Ejemplo n.º 12
0
            /// <summary>
            ///    Обновление решения
            /// </summary>
            /// <param name="isHangout">
            ///    true, если время на обновление вышло, а процесс все еще не завершен, false - если процесс
            ///    завершился
            /// </param>
            /// <param name="devenvExitCode"></param>
            /// <returns>true, если обновление прошло успешно, false - в противном случае</returns>
            public bool Upgrade(out bool isHangout, out int devenvExitCode)
            {
                var restoreResult = AnalyzerUtilities.IndividualRestore(_solutionFileName, _selfTesterRootPath,
                                                                        _srcEtalonFolder);

                if (!restoreResult.Item1)
                {
                    isHangout      = false;
                    devenvExitCode = default(int);
                    AppEventLogger.Log(restoreResult.Item2, EventLogEntryType.Error);
                    return(false);
                }

                try
                {
                    ConfigureUpgradeProcess();
                    _upgradeSlnProcess.Start();
                    var isSelfExit = IsSelfExit();
                    if (!isSelfExit) // Если сам не завершился, значит завис
                    {
                        ProcessUtils.MandatoryKill(_upgradeSlnProcess);
                        isHangout = true;
                        if (_upgradeSlnProcess.HasExited)
                        {
                            devenvExitCode = _upgradeSlnProcess.ExitCode;
                            return(false);
                        }
                    }

                    isHangout      = false;
                    devenvExitCode = _upgradeSlnProcess.HasExited ? _upgradeSlnProcess.ExitCode : default(int);
                    return(devenvExitCode == 0);
                }
                catch (Exception ex)
                {
                    AppEventLogger.Log(
                        string.Format("Error message: {0}{1}{2}", ex.Message, Environment.NewLine, ToString()),
                        EventLogEntryType.Error);
                    isHangout      = false;
                    devenvExitCode = default(int);
                    return(false);
                }
            }
Ejemplo n.º 13
0
        [STAThread] // Required for WinForms
        private static void Main(string[] args)
        {
            ProcessUtils.SanitizeEnvironmentVariables();
            NetUtils.ApplyProxy();

            WindowsUtils.SetCurrentProcessAppID("ZeroInstall.Publishing");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/"));

            var openPgp = OpenPgp.Signing();

            if (args.Length == 0)
            {
                Application.Run(new WelcomeForm(openPgp));
            }
            else
            {
                try
                {
                    var files = Paths.ResolveFiles(args, "*.xml");
                    if (files.Count == 1)
                    {
                        string path = files.First().FullName;
                        Application.Run(new MainForm(FeedEditing.Load(path), openPgp));
                    }
                    else
                    {
                        MassSignForm.Show(files);
                    }
                }
                #region Error handling
                catch (Exception ex) when(ex is ArgumentException or IOException or InvalidDataException)
                {
                    Msg.Inform(null, ex.GetMessageWithInner(), MsgSeverity.Warn);
                }
                catch (Exception ex) when(ex is UnauthorizedAccessException)
                {
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                }
                #endregion
            }
        }
Ejemplo n.º 14
0
        public async Task <GitBlameOutput[]> BlameReverse(string filePath, string baseCommit, string headCommit)
        {
            var handler  = new GitBlameOutputHandler();
            var gitBlame = new ProcessConfig("git", $"blame --reverse {baseCommit}..{headCommit} {filePath} -p",
                                             (s, b) =>
            {
                if (!b)
                {
                    handler.ReadLine(s);
                }
                if (b && !string.IsNullOrEmpty(s))
                {
                    Console.WriteLine($"Error git: {s}");
                }
            }, RepositoryPath);
            await ProcessUtils.RunProcess(gitBlame);

            return(handler.GetOutputs());
        }
        private void ClickSendButton()
        {
            if (null != _wait.Until(ExpectedConditions.ElementToBeClickable(_sendButtonElement)))
            {
                _actionsBuilder.MoveToElement(_sendButtonElement);
                _actionsBuilder.Click()
                .Perform();
            }
            else
            {
                ProcessUtils.ConsoleLog("ERROR: Send Button Not Available");
            }

            IWebElement messageSentInfo = _wait.Until(ExpectedConditions.ElementExists(By.XPath("//span[text()='Message sent.']")));

            _isMessageSent = _wait.Until(ExpectedConditions.TextToBePresentInElement(messageSentInfo, "Message sent."));

            ProcessUtils.ConsoleLog($"Message Sent: {_isMessageSent}");
        }
Ejemplo n.º 16
0
        public async Task <GitLogOutput[]> Log(string filePath, string baseCommit, string headCommit, Range lines)
        {
            var handler  = new GitLogOutputHandler();
            var gitBlame = new ProcessConfig("git",
                                             $"log --ancestry-path {baseCommit}..{headCommit} -L {lines.Start},{lines.End}:{filePath}", (s, b) =>
            {
                if (!b)
                {
                    handler.ReadLine(s);
                }
                if (b && !string.IsNullOrEmpty(s))
                {
                    Console.WriteLine($"Error git: {s}");
                }
            }, RepositoryPath);
            await ProcessUtils.RunProcess(gitBlame);

            return(handler.GetOutputs());
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Launches an application URI Scheme and waits for the target process to appear
        /// </summary>
        /// <param name="startInfo"></param>
        /// <param name="cancelToken">A cancellation token to configure how long Warden will wait.</param>
        /// <returns></returns>
        internal static async Task <bool> LaunchUri(WardenStartInfo startInfo, CancellationTokenSource cancelToken)
        {
            var(fileName, arguments, workingDirectory) = ValidateUri(startInfo);

            if (startInfo.AsUser)
            {
                if (!Api.StartProcessAndBypassUac(fileName, arguments, workingDirectory, out _))
                {
                    throw new WardenLaunchException(string.Format(Resources.Exception_Process_Not_Start, fileName, arguments));
                }
            }
            else
            {
                var processStartInfo = new ProcessStartInfo
                {
                    FileName         = fileName,
                    Arguments        = arguments,
                    WorkingDirectory = workingDirectory,
                    UseShellExecute  = true
                };
                using (var process = Process.Start(processStartInfo))
                {
                    if (process == null)
                    {
                        throw new WardenLaunchException(string.Format(Resources.Exception_Process_Not_Start, startInfo.FileName, startInfo.Arguments));
                    }
                }
            }
            while (!cancelToken.IsCancellationRequested)
            {
                using (var process = ProcessUtils.GetProcess(startInfo.TargetFileName))
                {
                    if (process != null)
                    {
                        return(true);
                    }
                }
                //aggressive poll
                await Task.Delay(TimeSpan.FromMilliseconds(100), cancelToken.Token);
            }
            return(false);
        }
        private async void GetProcesses(object parameter)
        {
            Collection <MonoProcess> processes = new Collection <MonoProcess> ();
            string prevStatus = Status;
            await Task.Run(() =>
            {
                Status = "Getting Processes";
                int cp = Process.GetCurrentProcess().Id;
                foreach (Process p in Process.GetProcesses())
                {
                    if (p.Id == cp || p.MainWindowHandle == IntPtr.Zero)
                    {
                        continue;
                    }
                    const ProcessAccessRights flags = ProcessAccessRights.PROCESS_QUERY_INFORMATION | ProcessAccessRights.PROCESS_VM_READ;
                    IntPtr handle;

                    if ((handle = Native.OpenProcess(flags, false, p.Id)) != IntPtr.Zero)
                    {
                        if (ProcessUtils.GetMonoModule(handle, out IntPtr mono))
                        {
                            processes.Add(new MonoProcess
                            {
                                MonoModule = mono,
                                Id         = p.Id,
                                Name       = p.ProcessName
                            });
                        }

                        Native.CloseHandle(handle);
                    }
                }
            });

            Processes = processes;
            RaisePropertyChanged("Processes");
            Status = prevStatus;
            if (Processes.Count > 0)
            {
                SelectedProcess = Processes.First();
            }
        }
Ejemplo n.º 19
0
        public void No_DLL_load_crashes_when_given_PFX(bool withMscorsnInPath)
        {
            var ilMergeExePath = typeof(ILMerge).Assembly.Location;
            var inputAssembly  = Assembly.GetExecutingAssembly();

            using (var outputFile = TempFile.WithExtension(".dll"))
            {
                var startInfo = new ProcessStartInfo(
                    ilMergeExePath,
                    $"{ShadowCopyUtils.GenerateILMergeLibCliSwitches(inputAssembly)} /keyfile:\"{TestFiles.TestPfx}\" /out:\"{outputFile}\" \"{inputAssembly.Location}\"")
                {
                    WorkingDirectory = Path.GetDirectoryName(inputAssembly.Location)
                };

                if (withMscorsnInPath)
                {
                    startInfo.EnvironmentVariables["PATH"] = $"{Environment.GetEnvironmentVariable("PATH")};{RuntimeEnvironment.GetRuntimeDirectory()}";
                }

                // The system runs .NET executables as 64-bit no matter what the architecture of the calling process is.
                var result = ProcessUtils.Run(startInfo);

                Assert.That(result.ToString(), Does.Not.Contain("Unable to load DLL 'mscorsn.dll'"));
                Assert.That(result.ToString(), Does.Not.Contain("An attempt was made to load a program with an incorrect format."));


                // Test failures:

                if (withMscorsnInPath && !Environment.Is64BitOperatingSystem)
                {
                    Assert.Inconclusive("This test can only be run on a 64-bit OS.");
                }

                Assert.That(
                    result.ToString(),
                    Does.Not.Contain("Unhandled Exception: System.IO.FileNotFoundException"),
                    "The test is not being run properly. If you are using ReSharper, disable shadow copy. " +
                    "If you are using NCrunch, go to NCrunch's configuration for the ILMerge project and " +
                    "make sure \"Copy referenced assemblies to workspace\" is set to True. " +
                    "(Both ReSharper and NCrunch settings are saved in the repo, so this should not happen.)");
            }
        }
Ejemplo n.º 20
0
    public async Task Publish_ui()
    {
        Directory.SetCurrentDirectory(ProjectDir);
        FromModulesDir.Print();
        ToModulesDir.Print();

        //publish tailwind
        await ProcessUtils.RunShellAsync("npm run ui:build",
                                         onOut :   Console.WriteLine,
                                         onError : Console.Error.WriteLine);

        // copy to modules/ui
        transformOptions.CopyAll(
            source: new FileSystemVirtualFiles(FromModulesDir.CombineWith("ui")),
            target: new FileSystemVirtualFiles(ToModulesDir.CombineWith("ui")),
            cleanTarget: true,
            ignore: file => IgnoreUiFiles.Contains(file.VirtualPath),
            afterCopy: (file, contents) => $"{file.VirtualPath} ({contents.Length})".Print());

        // copy to modules/locode
        transformOptions.CopyAll(
            source: new FileSystemVirtualFiles(FromModulesDir.CombineWith("locode")),
            target: new FileSystemVirtualFiles(ToModulesDir.CombineWith("locode")),
            cleanTarget: true,
            ignore: file => IgnoreUiFiles.Contains(file.VirtualPath),
            afterCopy: (file, contents) => $"{file.VirtualPath} ({contents.Length})".Print());

        // copy to modules/admin-ui
        transformOptions.CopyAll(
            source: new FileSystemVirtualFiles(FromModulesDir.CombineWith("admin-ui")),
            target: new FileSystemVirtualFiles(ToModulesDir.CombineWith("admin-ui")),
            cleanTarget: true,
            ignore: file => IgnoreAdminUiFiles.Contains(file.VirtualPath),
            afterCopy: (file, contents) => $"{file.VirtualPath} ({contents.Length})".Print());

        // copy to modules/shared
        transformOptions.CopyAll(
            source: new FileSystemVirtualFiles(FromModulesDir.CombineWith("shared")),
            target: new FileSystemVirtualFiles(ToModulesDir.CombineWith("shared")),
            cleanTarget: true,
            afterCopy: (file, contents) => $"{file.VirtualPath} ({contents.Length})".Print());
    }
Ejemplo n.º 21
0
 private static void WaitUntilClientServerReady(string vmName)
 {
     Logger.Info("Starting client");
     ProcessUtils.GetProcessObject(Utils.GetPartnerExecutablePath(), vmName, false).Start();
     while (true)
     {
         try
         {
             if (HTTPUtils.SendRequestToClient("ping", (Dictionary <string, string>)null, vmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp").Contains("true", StringComparison.InvariantCultureIgnoreCase))
             {
                 break;
             }
         }
         catch (Exception ex)
         {
             Logger.Warning("Partner server not ready yet. Err: " + ex.Message);
         }
         Thread.Sleep(1000);
     }
 }
Ejemplo n.º 22
0
        private void btnLaunchWhatsApp_Click(object sender, RoutedEventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            string packagename = "com.whatsapp";

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];

                if (vmIndex != -1)
                {
                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Sets the final results of the list of current data records and writes this list to the corresponding data log file.
        /// </summary>
        /// <param name="finalResult">The final result.</param>
        public void WriteListOfDataRecordsToFile(TResult finalResult)
        {
            lock (this._lock)
            {
                this.AddFinalDataRecordIfMissing(finalResult);

                // Set final results.
                this._listOfDataRecords.ForEach(x => x.TunerDataRecord.FinalResult = finalResult);

                // Write data records to corresponding data log file.
                var dataLogFileName = GrayBoxUtils.GetDataLogFileName(
                    this._tunerDataRecord.GenerationId,
                    ProcessUtils.GetCurrentProcessId(),
                    this._actorId,
                    finalResult.TargetAlgorithmStatus);
                var dataRecorder =
                    new DataRecorder <TResult>(new FileInfo(Path.Combine(this._configuration.DataRecordDirectoryPath, dataLogFileName)));
                dataRecorder.WriteRows(this._listOfDataRecords);
            }
        }
Ejemplo n.º 24
0
        private void btnInit_Click(object sender, EventArgs e)
        {
            ProcessUtils.LDPath = txtPath.Text;
            if (ProcessUtils.LDPath == "")
            {
                MessageBox.Show("请先选择雷电模拟器路径");
                return;
            }
            Simulator simulator = new Simulator()
            {
                Cpu    = 1,
                Memory = 1024,
                Width  = 320,
                Height = 480,
                Dpi    = 240,
                Imei   = "auto"
            };

            ProcessUtils.Init(simulator);
        }
Ejemplo n.º 25
0
        private static Task <bool> RunCommandAsync(string command, Action <string> outputAction, Context context = null)
        {
            var actualCommand = FormatCommand(command, context, jsonFormat: false);
            Dictionary <string, string> environment = null;

            if (context?.AppName != null)
            {
                environment = new Dictionary <string, string> {
                    { GCloudMetricsVariable, context?.AppName }
                };
                if (context?.AppVersion != null)
                {
                    environment[GCloudMetricsVersionVariable] = context?.AppVersion;
                }
            }

            // This code depends on the fact that gcloud.cmd is a batch file.
            Debug.Write($"Executing gcloud command: {actualCommand}");
            return(ProcessUtils.RunCommandAsync("cmd.exe", $"/c {actualCommand}", (o, e) => outputAction(e.Line), environment));
        }
Ejemplo n.º 26
0
        private void btnCloseWhatsApp_Click(object sender, RoutedEventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo));
                return;
            }

            string packagename = "com.whatsapp";

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];

                if (vmIndex != -1)
                {
                    ProcessUtils.AdbCloseApps(vmIndex, packagename);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates an app bundle by publishing it to the given directory. It only publishes the release configuration.
        /// </summary>
        /// <param name="projectPath">The full path to the project to publish.</param>
        /// <param name="stageDirectory">The directory to which to publish.</param>
        /// <param name="outputAction">The callback to call with output from the command.</param>
        internal static Task <bool> CreateAppBundleAsync(string projectPath, string stageDirectory, Action <string> outputAction)
        {
            var arguments     = $"publish -o \"{stageDirectory}\" -c Release";
            var externalTools = GetExternalToolsPath();
            var workingDir    = Path.GetDirectoryName(projectPath);
            var env           = new Dictionary <string, string>
            {
                { "PATH", $"{Environment.GetEnvironmentVariable("PATH")};{externalTools}" },
            };

            Debug.WriteLine($"Using tools from {externalTools}");
            Debug.WriteLine($"Setting working directory to {workingDir}");
            outputAction($"dotnet {arguments}");
            return(ProcessUtils.RunCommandAsync(
                       file: s_dotnetPath.Value,
                       args: arguments,
                       workingDir: workingDir,
                       handler: (o, e) => outputAction(e.Line),
                       environment: env));
        }
Ejemplo n.º 28
0
        //private void CheckBlock2(object state)
        //{
        //    if (_killServerResult == null)
        //    {
        //        Console.WriteLine("_killServerResult is null");
        //        _checkBlockTimer2.Change(4000, Timeout.Infinite);
        //        Task.Run(() =>
        //        {
        //            _killServerResult = ProcessUtils.KillAdbServer();
        //        });
        //    }
        //    else
        //    {
        //        if (_startServerResult == null)
        //        {
        //            Console.WriteLine("_startServerResult is null");
        //            _checkBlockTimer2.Change(4000, Timeout.Infinite);
        //            Task.Run(() =>
        //            {
        //                _startServerResult = ProcessUtils.StartAdbServer();
        //            });
        //        }
        //        else
        //        {
        //            LaunchAndroidTestOnTheBackground(1000);
        //        }
        //    }
        //}

        //public void ReconnectDevices()
        //{
        //    Devices = new string[0];

        //    if (VmManager.Instance.RunningGroupIndex == -1)
        //    {
        //        MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));

        //        return;
        //    }

        //    lock (TimerSyncObj)
        //    {
        //        _checkCountTimer.Change(Timeout.Infinite, Timeout.Infinite);
        //    }

        //    EventAggregatorManager.Instance.EventAggregator.GetEvent<VmClosedEvent>().Publish();

        //    _checkBlockTimer2.Change(1000, Timeout.Infinite);
        //}

        private void CheckBlock(object state)
        {
            if (_rawDevices == null)
            {
                Console.WriteLine("TRY getting attached devices");
                _checkBlockTimer.Change(6000, Timeout.Infinite);
                Task.Run(() =>
                {
                    _rawDevices = ProcessUtils.GetAttachedDevices();
                });
            }
            else
            {
                Console.WriteLine($"TRY getting attached devices SUCCESSFULLY, count={_rawDevices?.Length}");
                //lock (TimerSyncObj)
                //{
                _checkCountTimer.Change(1000, Timeout.Infinite);
                //}
            }
        }
Ejemplo n.º 29
0
        public bool IsLabelApplied(string strLabel)
        {
            try
            {
                foreach (IWebElement labelCheckbox in _browserDriver.FindElements(By.XPath($"//*[@role='menuitemcheckbox' and @title='{strLabel}']")))
                {
                    Console.WriteLine($"labelCheckbox.GetAttribute('aria-checked'): {labelCheckbox.GetAttribute("aria-checked")}");
                    if (labelCheckbox.GetAttribute("aria-checked").Equals("true"))
                    {
                        return(true);
                    }
                }
            }
            catch (WebDriverTimeoutException timeout)
            {
                ProcessUtils.ConsoleLog(timeout.Message);
            }

            return(false);
        }
Ejemplo n.º 30
0
        public static string FindDataPathFromRunningWallet(string ProcessName)
        {
            Debug.WriteLine("Looking for running namecoin wallet...");

            var processes = System.Diagnostics.Process.GetProcessesByName(ProcessName);
            int count     = processes.Count();

            if (count <= 0)
            {
                return(null);
            }

            if (count > 1)
            {
                InvokeNamecoinConfigInfo(string.Format("There may be {0} namecoin wallet processes open. Please close {1} and restart service.", count, count - 1), true);
            }

            var    process = processes.First();
            string cmdline = ProcessUtils.GetProcessCommandline(process);

            if (cmdline == null)
            {
                InvokeNamecoinConfigInfo("Run Namecoin as current user.", true);
                return(null);
            }

            string path = GetCustomDataDirectory(cmdline);

            if (path != null)
            {
                return(path);
            }

            path = ProcessUtils.TryFindOwnerAppDataPath(process);
            if (path != null)
            {
                return(System.IO.Path.Combine(path, NmcDataFolder));
            }

            return(null);
        }