private void RunPythonAutomation(Job job, Automation automation, MachineCredential machineCredential, string mainScriptFilePath)
        {
            string pythonExecutable = GetPythonPath(machineCredential.UserName, "");
            string projectDir       = Path.GetDirectoryName(mainScriptFilePath);

            string commandsBatch = $"\"{pythonExecutable}\" -m pip install --upgrade pip && " +
                                   $"\"{pythonExecutable}\" -m pip install --user virtualenv && " +
                                   $"\"{pythonExecutable}\" -m venv \"{Path.Combine(projectDir, ".env3")}\" && " +
                                   $"\"{Path.Combine(projectDir, ".env3", "Scripts", "activate.bat")}\" && " +
                                   (File.Exists(Path.Combine(projectDir, "requirements.txt")) ? $"\"{pythonExecutable}\" -m pip install -r \"{Path.Combine(projectDir, "requirements.txt")}\" & " : "") +
                                   $"\"{pythonExecutable}\" \"{mainScriptFilePath}\" && " +
                                   $"deactivate";

            string batchFilePath = Path.Combine(projectDir, job.Id.ToString() + ".bat");

            File.WriteAllText(batchFilePath, commandsBatch);
            string logsFilePath = $"{mainScriptFilePath}.log";
            string cmdLine      = $"\"{batchFilePath}\" > \"{logsFilePath}\"";

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, machineCredential, out procInfo);

            var executionParams = GetJobExecutionParams(job, automation, mainScriptFilePath, null);

            SendLogsToServer(mainScriptFilePath, executionParams);

            return;
        }
Esempio n. 2
0
        private void RunPythonAutomation(string mainScriptFilePath, string projectName, ServerConnectionSettings settings)
        {
            string pythonExecutable = _executionManager.GetPythonPath(settings.UserName, "");
            string projectDir       = Path.GetDirectoryName(mainScriptFilePath);

            string commandsBatch = $"\"{pythonExecutable}\" -m pip install --upgrade pip && " +
                                   $"\"{pythonExecutable}\" -m pip install --user virtualenv && " +
                                   $"\"{pythonExecutable}\" -m venv \"{Path.Combine(projectDir, ".env3")}\" && " +
                                   $"\"{Path.Combine(projectDir, ".env3", "Scripts", "activate.bat")}\" && " +
                                   (File.Exists(Path.Combine(projectDir, "requirements.txt")) ? $"\"{pythonExecutable}\" -m pip install -r \"{Path.Combine(projectDir, "requirements.txt")}\" & " : "") +
                                   $"\"{pythonExecutable}\" \"{mainScriptFilePath}\" && " +
                                   $"deactivate";

            string batchFilePath = Path.Combine(projectDir, projectName + ".bat");

            File.WriteAllText(batchFilePath, commandsBatch);
            string logsFilePath = GetLogsFilePath(settings.LoggingValue1, AutomationType.Python, projectName);

            string cmdLine  = $"\"{batchFilePath}\" > \"{logsFilePath}\"";
            var    userInfo = new MachineCredential
            {
                Domain   = settings.DNSHost,
                UserName = settings.UserName
            };

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, userInfo, out procInfo);

            return;
        }
        private void RunOpenBotsAutomation(Job job, Automation automation, MachineCredential machineCredential, string mainScriptFilePath, List <string> projectDependencies)
        {
            var executionParams = GetExecutionParams(job, automation, mainScriptFilePath, projectDependencies);
            var executorPath    = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "OpenBots.Executor.exe").FirstOrDefault();
            var cmdLine         = $"\"{executorPath}\" \"{executionParams}\"";

            // launch the Executor
            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, machineCredential, out procInfo);
            return;
        }
        private void RunPythonAutomation(Job job, MachineCredential machineCredential, string mainScriptFilePath)
        {
            string projectDir       = Path.GetDirectoryName(mainScriptFilePath);
            string assemblyPath     = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pythonExecutable = GetPythonPath(machineCredential.UserName, "");
            string cmdLine          = $"powershell.exe -File \"{assemblyPath}\\Executors\\PythonExecutor.ps1\" \"{pythonExecutable}\" \"{projectDir}\" \"{mainScriptFilePath}\"";

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, machineCredential, out procInfo);

            return;
        }
Esempio n. 5
0
        private void RunAttendedAutomation(string mainScriptFilePath, ServerConnectionSettings settings, List <string> projectDependencies)
        {
            var executionParams = GetExecutionParams(mainScriptFilePath, settings, projectDependencies);
            var userInfo        = new MachineCredential
            {
                Domain   = settings.DNSHost,
                UserName = settings.UserName
            };

            var executorPath = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "OpenBots.Executor.exe").FirstOrDefault();
            var cmdLine      = $"\"{executorPath}\" \"{executionParams}\"";

            // launch the Executor
            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, userInfo, out procInfo);
        }
Esempio n. 6
0
        private void RunCSharpAutomation(string mainScriptFilePath, string projectName, ServerConnectionSettings settings)
        {
            string exePath = _executionManager.GetFullPathFromWindows("cscs.exe", settings.DNSHost, settings.UserName);

            if (exePath == null)
            {
                throw new Exception("CS-Script installation was not detected on the machine. Please perform the installation as outlined in the official documentation.");
            }

            var    logsFilePath = GetLogsFilePath(settings.LoggingValue1, AutomationType.CSScript, projectName);
            string cmdLine      = $"C:\\Windows\\System32\\cmd.exe /C cscs \"{mainScriptFilePath}\" > \"{logsFilePath}\"";
            var    userInfo     = new MachineCredential
            {
                Domain   = settings.DNSHost,
                UserName = settings.UserName
            };

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, userInfo, out procInfo);

            return;
        }
        private void RunCSharpAutomation(Job job, Automation automation, MachineCredential machineCredential, string mainScriptFilePath)
        {
            string exePath = GetFullPathFromWindows("cscs.exe", _connectionSettingsManager.ConnectionSettings.DNSHost,
                                                    _connectionSettingsManager.ConnectionSettings.UserName);

            if (exePath == null)
            {
                throw new Exception("CS-Script installation was not detected on the machine. Please perform the installation as outlined in the official documentation.");
            }

            var    logsFilePath = $"{mainScriptFilePath}.log";
            string cmdLine      = $"C:\\Windows\\System32\\cmd.exe /C cscs \"{mainScriptFilePath}\" > \"{logsFilePath}\"";

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, machineCredential, out procInfo);

            var executionParams = GetJobExecutionParams(job, automation, mainScriptFilePath, null);

            SendLogsToServer(mainScriptFilePath, executionParams);

            return;
        }
Esempio n. 8
0
        private void RunTagUIAutomation(string mainScriptFilePath, string projectName, ServerConnectionSettings settings, string executionDirPath)
        {
            string exePath = _executionManager.GetFullPathFromWindows("tagui", settings.DNSHost, settings.UserName);

            if (exePath == null)
            {
                throw new Exception("TagUI installation was not detected on the machine. Please perform the installation as outlined in the official documentation.");
            }

            // Create "tagui_logging" file for generating logs file
            var logFilePath = Path.Combine(Directory.GetParent(exePath).FullName, "tagui_logging");

            if (!File.Exists(logFilePath))
            {
                File.Create(Path.Combine(Directory.GetParent(exePath).FullName, "tagui_logging"));
            }

            // Copy Script Folder/Files to ".\tagui\flows" Directory
            var mainScriptPath = _executionManager.CopyTagUIAutomation(exePath, mainScriptFilePath, ref executionDirPath);
            var logsFilePath   = GetLogsFilePath(settings.LoggingValue1, AutomationType.TagUI, projectName);

            string cmdLine  = $"C:\\Windows\\System32\\cmd.exe /C tagui \"{mainScriptPath}\" > \"{logsFilePath}\"";
            var    userInfo = new MachineCredential
            {
                Domain   = settings.DNSHost,
                UserName = settings.UserName
            };

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, userInfo, out procInfo);

            // Delete TagUI Execution Directory
            Directory.Delete(executionDirPath, true);

            return;
        }
        private void RunTagUIAutomation(Job job, Automation automation, MachineCredential machineCredential,
                                        string mainScriptFilePath, string executionDirPath)
        {
            string exePath = GetFullPathFromWindows("tagui", _connectionSettingsManager.ConnectionSettings.DNSHost,
                                                    _connectionSettingsManager.ConnectionSettings.UserName);

            if (exePath == null)
            {
                throw new Exception("TagUI installation was not detected on the machine. Please perform the installation as outlined in the official documentation.");
            }

            // Create "tagui_logging" file for generating logs file
            var logFilePath = Path.Combine(Directory.GetParent(exePath).FullName, "tagui_logging");

            if (!File.Exists(logFilePath))
            {
                File.Create(Path.Combine(Directory.GetParent(exePath).FullName, "tagui_logging"));
            }

            // Copy Script Folder/Files to ".\tagui\flows" Directory
            var mainScriptPath = CopyTagUIAutomation(exePath, mainScriptFilePath, ref executionDirPath);

            string cmdLine = $"C:\\Windows\\System32\\cmd.exe /C tagui \"{mainScriptPath}\"";

            ProcessLauncher.PROCESS_INFORMATION procInfo;
            ProcessLauncher.LaunchProcess(cmdLine, machineCredential, out procInfo);

            var executionParams = GetJobExecutionParams(job, automation, mainScriptPath, null);

            SendLogsToServer(mainScriptPath, executionParams);

            // Delete TagUI Execution Directory
            Directory.Delete(executionDirPath, true);

            return;
        }