private void btnCreateVen_ClickAsync(object sender, EventArgs e) { if (txtNumberVen.Text == "" || txtNumLoads.Text == "") { MessageBox.Show("Data input is not valid !"); return; } var settings = new IniFile("Settings.ini"); // settings.Write("VEN Name", txtvenID.Text, "Ven Settings"); // settings.Write("VEN ID", txtVenName.Text, "Ven Settings"); settings.Write("URL", txtUrl.Text, "Ven Settings"); settings.Write("MaxVen", txtNumberVen.Text, "Ven Settings"); settings.Write("MaxLoads", txtNumLoads.Text, "Ven Settings"); settings.Write("HideVen", chkHidevens.Checked.ToString(), "Ven Settings"); settings.Write("MaxThread", txtMaxthread.Text, "Ven Settings"); var Path = AppDomain.CurrentDomain.BaseDirectory + "/VenCenter.exe"; var res = ProcessAsyncHelper.RunProcessAsync(Path, "start -n " + txtNumberVen.Text + " -l " + txtNumLoads.Text + " -t " + txtMaxthread.Text + (chkHidevens.Checked ? "":" -s"), 3 * 60 * 1000).ConfigureAwait(false); this.Close(); }
private async void Compile(Action func) { String generatedSourceFile = Path.Combine(new FileInfo(Mapset.Path).Directory.FullName, "maps.asm"); ASM.Export(generatedSourceFile, AsmBaseLineFullPath, Mapset); AddLine($"{Environment.NewLine}**Generating {GetXEXFullPath()} **{Environment.NewLine}", Color.Red); String arguments = $"-i:\"{Path.GetDirectoryName(generatedSourceFile)}\" \"{generatedSourceFile}\" -o:\"{GetXEXFullPath()}\""; if (firstmap > 0) { arguments += $" -d:BLCK_MAPSTART={firstmap}"; } AddLine(arguments, Color.Red); var processResult = await ProcessAsyncHelper.RunProcessAsync(MADSFullPath, arguments, -1, P_OutputDataReceived, p_ErrorDataReceived); // Mads Exit codes // 3 = bad parameters, assembling not started // 2 = error occured // 0 = no errors buttonOK.Enabled = true; if (processResult.ExitCode == 0) { func(); } }
private void button2_Click(object sender, EventArgs e) { var Path = AppDomain.CurrentDomain.BaseDirectory + "/VenCenter.exe"; var res = ProcessAsyncHelper.RunProcessAsync(Path, "stop -all ", 3 * 60 * 1000).ConfigureAwait(false); this.Close(); }
public static Task <ProcessAsyncHelper.ProcessResult> Bash(this string cmd, bool shouldWaitToExit = false) { var escapedArgs = cmd.Replace("\"", "\\\""); return(ProcessAsyncHelper.ExecuteShellCommand("/bin/bash", new[] { $"-c \"{escapedArgs}\"" }, shouldWaitToExit, CancellationToken.None)); }
private async Task <string> ConvertFileToPdf(string filePath) { var exePath = "chordpro.exe"; // Create temp config file path var configurationFilePath = Path.GetTempPath() + Guid.NewGuid() + ".json"; File.WriteAllText(configurationFilePath, _configurationService.LoadConfigurationFileText()); //var configFilePath = _globalContext.ConfigFilePath; if (string.IsNullOrEmpty(configurationFilePath)) { await ShowErrorMessage("Chordpro config file not defined"); return(null); } var filename = Path.GetFileName(filePath); if (string.IsNullOrEmpty(filename)) { await ShowErrorMessage("Input file not defined"); return(null); } var directoryPath = Path.GetDirectoryName(filePath); if (string.IsNullOrEmpty(directoryPath)) { await ShowErrorMessage("Directory not found"); return(null); } var outputFilePath = directoryPath + "\\" + filename.Replace(".cho", ".pdf"); var arguments = $"\"{filePath}\" -o \"{outputFilePath}\" --cfg \"{configurationFilePath}\""; if (!string.IsNullOrEmpty(TextSize)) { arguments += $" --text-size={TextSize}"; } var result = await ProcessAsyncHelper.ExecuteShellCommand(exePath, arguments, int.MaxValue); var error = result.Output; if (!string.IsNullOrEmpty(error)) { await ShowErrorMessage(error); return(null); } return(outputFilePath); }
public void StartWorker() { ProcessStartInfo startInfo = new ProcessStartInfo("python3"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; startInfo.Arguments = $"test.py tcp://127.0.0.1:{_portNumber} {_portNumber}"; ProcessAsyncHelper.RunAsync(startInfo); _consumeQueueTask = Task.Run(ConsumeQueue); }
public async Task <ProcessResult> GenerateServerCode(string rootWebAPIProjectNameSuffix, CodeGenConfig config) { var jsonfile = config.SwaggerFile; var strJarFilePath = Directory.GetCurrentDirectory() + "\\" + SWAGGER_CODEGEN_JAR; var mustacheTemplatePath = Directory.GetCurrentDirectory() + @"\SwaggerCodeGen\AspDotNetCoreMustacheTemplate"; var rootApiProjectName = config.PackageName + "." + rootWebAPIProjectNameSuffix; return(await ProcessAsyncHelper.RunProcessAsync("java.exe", $"-jar {strJarFilePath} generate -i {jsonfile} -t {mustacheTemplatePath} -DpackageName={rootApiProjectName} -l aspnetcore -o {config.outputFolderPath}", 30000).ConfigureAwait(false)); }
public ProgressDialog(string arg) { Instance = this; // 다운로드 실행 var youtubeDl = ((App)Application.Current).YoutubeDlPath; process = ProcessAsyncHelper.RunProcessAsync(youtubeDl, arg, int.MaxValue); InitializeComponent(); }
static async void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { var pugFilePaths = importedAssets .Where(filePath => filePath.Split('.')[1] == "pug"); foreach (var filePath in pugFilePaths) { var fileName = filePath.Split('.')[0]; var dataPath = Application.dataPath.Replace("/Assets", ""); var args = $"{dataPath}/{fileName}.pug -P"; var process = ProcessAsyncHelper.RunProcessAsync( Pug, args, 1000, (PathName, PathPath)); await process; // When it's done, insert the UIElements boilerplate var tempOutput = File.ReadAllText(fileName + ".html"); var insertIndex = tempOutput.IndexOf("<UXML", StringComparison.Ordinal); var uxmlString = tempOutput.Insert(insertIndex + 5, " xmlns:xsi=\"http:/www.w3.org/2001/XMLSchema-instance\"" + " xmlns=\"UnityEngine.UIElements\"" + " xsi:noNamespaceSchemaLocation=\"../UIElementsSchema/UIElements.xsd\"" + " xsi:schemaLocation=\"UnityEngine.UIElements ../UIElementsSchema/UnityEngine.UIElements.xsd\""); File.Delete(fileName + ".html"); var uxmlDoc = new XmlDocument(); uxmlDoc.LoadXml(uxmlString); var settings = new XmlWriterSettings { Indent = true }; // Save the document to a file and auto-indent the output. var writer = XmlWriter.Create(fileName + ".uxml", settings); uxmlDoc.Save(writer); writer.Dispose(); } }
static void Main(string[] args) { string cleaned = File.ReadAllText("data.txt").Replace("\n", "").Replace("\r", ""); int clients = int.Parse(args[0]); for (int i = 0; i < clients; i++) { System.Threading.Thread.Sleep(10000); Console.WriteLine($"starting test {i}"); ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "RunChromeHeadLess.bat"; ProcessAsyncHelper.RunAsync(startInfo); } Console.WriteLine("Now just wait, and dont press any key"); Console.ReadKey(); }
protected override void OnClosing(CancelEventArgs e) { if (!process.IsCompleted) { var message = this.ShowModalMessageExternal("Stop", "해당 파일을 받고 있습니다. 종료할까요?", MessageDialogStyle.AffirmativeAndNegative); if (message == MessageDialogResult.Affirmative) { ProcessAsyncHelper.StopProcess(); } else { e.Cancel = true; } } base.OnClosing(e); }
private void GenerateRelease() { Compile(async() => { String ExomizerFullPath = Properties.Settings.Default["ExomizerFullPath"].ToString(); String EmulatorCommandLine = Properties.Settings.Default["EmulatorCommandLine"].ToString(); if (File.Exists(ExomizerFullPath)) { var maxAdr = XEX.Load(GetXEXFullPath()).GetMaxAdr() + 2; var arguments = $"sfx sys -x3 \"{GetXEXFullPath()}\" -Di_table_addr={maxAdr} -t 168 -o \"{GetPackedXEXFullPath()}\""; AddLine($"{Environment.NewLine}** {arguments} **{Environment.NewLine}", Color.Red); var processResult = await ProcessAsyncHelper.RunProcessAsync(ExomizerFullPath, arguments, -1, P_OutputDataReceived, p_ErrorDataReceived); // DialogResult = DialogResult.OK; } }); }
public async Task <IAnalysis> AnalyzeAsync(string pdfPath, IProgress <int> pageProgress = null, CancellationToken ct = default) { var p2t = GetPdfToTextExePath(); if (!File.Exists(p2t)) { throw new PopplerNotFoundException($"The file {p2t} was not found. This application needs poppler to work properly. Please download poppler and extract it at the given location. You may download poppler at {PopplerDownloadUrl}.", p2t); } var output = System.IO.Path.GetTempFileName(); var arg = $"{PdfToTextArgs} \"{pdfPath}\" \"{output}\""; var res = await ProcessAsyncHelper.RunProcessAsync(p2t, arg, PdfToTextTimeout).ConfigureAwait(false); if (res.ExitCode != 0) { throw new ApplicationException($"PdfToText exited with code {res.ExitCode?.ToString() ?? "null"}. StdErr: {res.Error}"); } var analysis = await ParseXmlAsync(output, pageProgress, ct).ConfigureAwait(false); System.IO.File.Delete(output); return(analysis); }
public async Task TestProcessHelper() { await ProcessAsyncHelper.ExecuteShellCommand("nodejs.exe", ".\\private_module\\index.js tt ss", 10000); Assert.True(true); }
private async void Btn_Build_Click(object sender, EventArgs e) { list_Logs.Items.Clear(); list_Logs.Items.Add(Text); list_Logs.Items.Add(""); string buildNumber = Path.GetRandomFileName().Replace(".", "").Substring(4); Log($"Build started for Legacy of Solaris (Build: {buildNumber})..."); string repository = Path.Combine(text_Repository.Text, "Legacy of Solaris"); string platformString = string.Empty; string buildDir = string.Empty; int system = 0; if (radio_Xbox360.Checked) { platformString = "Xbox 360"; system = 0; } else if (radio_PlayStation3.Checked) { platformString = "PlayStation 3"; system = 1; } if (Directory.Exists(repository)) { List <string> xscripts = Directory.GetFiles(repository, "*.xscript", SearchOption.AllDirectories).ToList(); List <string> pscripts = Directory.GetFiles(repository, "*.pscript", SearchOption.AllDirectories).ToList(); try { if (system == 0) { if (check_ForceParams.Checked) { foreach (string script in pscripts) { File.Move(script, Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub")); } } else { foreach (string script in xscripts) { File.Move(script, Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub")); } } } else if (system == 1) { if (check_ForceParams.Checked) { foreach (string script in xscripts) { File.Move(script, Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub")); } } else { foreach (string script in pscripts) { File.Move(script, Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub")); } } } } catch { } if (Directory.Exists(text_BuildLocation.Text)) { buildDir = Path.Combine(text_BuildLocation.Text, $"Legacy of Solaris ({buildNumber})"); Directory.CreateDirectory(buildDir); InterfaceState(false); } else { Log($"Failed to build Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); UnifyMessages.UnifyMessage.Show("Please specify a valid build location...", "Path Error", "OK", "Error"); InterfaceState(true); return; } if (Directory.Exists(text_GameDirectory.Text)) { List <string> directories = Directory.GetDirectories(repository, "*.arc", SearchOption.AllDirectories).ToList(); List <string> xfiles = Directory.GetFiles(repository, "*.*", SearchOption.AllDirectories) .Where(s => s.ToLower().EndsWith("default.xex") || s.ToLower().EndsWith(".wmv") || s.ToLower().EndsWith(".xma")).ToList(); //X-Files lol List <string> psfiles = Directory.GetFiles(repository, "*.*", SearchOption.AllDirectories) .Where(s => s.ToLower().EndsWith("eboot.bin") || s.ToLower().EndsWith(".pam") || s.ToLower().EndsWith(".at3")).ToList(); int errorCount = 0; if (radio_Standalone.Checked) { foreach (string archive in directories) { Log($"Repacking {Path.GetFileName(archive)} to Legacy of Solaris (Build: {buildNumber})..."); try { List <string> getArchive = Directory.GetFiles(text_GameDirectory.Text, Path.GetFileName(archive), SearchOption.AllDirectories).ToList(); string arcPath = getArchive[0].Remove(0, text_GameDirectory.Text.Length).Substring(1); Directory.CreateDirectory(Path.Combine(buildDir, Path.GetDirectoryName(arcPath))); MergeARCs(getArchive[0], archive, Path.Combine(buildDir, arcPath), system); } catch { Log($"Failed to repack '{Path.GetFileName(archive)}' to Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); errorCount++; } } var metadataWrite = File.Create(Path.Combine(buildDir, "mod.ini")); var metadataSession = new UTF8Encoding(true).GetBytes("Title=\"Legacy of Solaris\"\n" + $"Version=\"{buildNumber}\"\n" + $"Date=\"{DateTime.Now.ToString("dd/MM/yyyy")}\"\n" + $"Author=\"Lost Legacy Team\"\n" + $"Platform=\"{platformString}\"\n" + "Merge=\"False\""); metadataWrite.Write(metadataSession, 0, metadataSession.Length); metadataWrite.Close(); } else if (radio_Merge.Checked) { foreach (string archive in directories) { Log($"Repacking {Path.GetFileName(archive)} to Legacy of Solaris (Build: {buildNumber})..."); try { List <string> getArchive = Directory.GetFiles(text_GameDirectory.Text, Path.GetFileName(archive), SearchOption.AllDirectories).ToList(); string arcPath = getArchive[0].Remove(0, text_GameDirectory.Text.Length).Substring(1); Directory.CreateDirectory(Path.Combine(buildDir, Path.GetDirectoryName(arcPath))); if (Directory.GetDirectories(archive, "_core", SearchOption.AllDirectories).Length > 0) { foreach (string core in Directory.GetDirectories(archive, "_core", SearchOption.AllDirectories)) { if (system == 0) { Directory.Move(core, Path.Combine(Path.GetDirectoryName(core), "xenon")); } else if (system == 1) { Directory.Move(core, Path.Combine(Path.GetDirectoryName(core), "ps3")); } } } else if (Directory.GetDirectories(archive, "xenon", SearchOption.AllDirectories).Length > 0) { foreach (string core in Directory.GetDirectories(archive, "xenon", SearchOption.AllDirectories)) { if (system == 1) { Directory.Move(core, Path.Combine(Path.GetDirectoryName(core), "ps3")); } } } else if (Directory.GetDirectories(archive, "ps3", SearchOption.AllDirectories).Length > 0) { foreach (string core in Directory.GetDirectories(archive, "ps3", SearchOption.AllDirectories)) { if (system == 0) { Directory.Move(core, Path.Combine(Path.GetDirectoryName(core), "xenon")); } } } await ProcessAsyncHelper.ExecuteShellCommand(Program.arctool, $"-i \"{archive}\" -c \"{Path.Combine(buildDir, arcPath)}\"", Application.StartupPath, 100000); if (Directory.GetDirectories(archive, "xenon", SearchOption.AllDirectories).Length > 0) { foreach (string core in Directory.GetDirectories(archive, "xenon", SearchOption.AllDirectories)) { Directory.Move(core, Path.Combine(Path.GetDirectoryName(core), "_core")); } } else if (Directory.GetDirectories(archive, "ps3", SearchOption.AllDirectories).Length > 0) { foreach (string core in Directory.GetDirectories(archive, "ps3", SearchOption.AllDirectories)) { Directory.Move(core, Path.Combine(Path.GetDirectoryName(core), "_core")); } } } catch { Log($"Failed to repack '{Path.GetFileName(archive)}' to Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); errorCount++; } } var metadataWrite = File.Create(Path.Combine(buildDir, "mod.ini")); var metadataSession = new UTF8Encoding(true).GetBytes("Title=\"Legacy of Solaris\"\n" + $"Version=\"{buildNumber}\"\n" + $"Date=\"{DateTime.Now.ToString("dd/MM/yyyy")}\"\n" + $"Author=\"Lost Legacy Team\"\n" + $"Platform=\"{platformString}\"\n" + "Merge=\"True\""); metadataWrite.Write(metadataSession, 0, metadataSession.Length); metadataWrite.Close(); } if (system == 0) { foreach (string content in xfiles) { Log($"Copying {Path.GetFileName(content)} to Legacy of Solaris (Build: {buildNumber})..."); try { List <string> getFile = Directory.GetFiles(text_GameDirectory.Text, Path.GetFileName(content), SearchOption.AllDirectories).ToList(); string filePath = getFile[0].Remove(0, text_GameDirectory.Text.Length).Substring(1); Directory.CreateDirectory(Path.Combine(buildDir, Path.GetDirectoryName(filePath))); File.Copy(content, Path.Combine(buildDir, filePath), true); } catch { Log($"Failed to copy '{Path.GetFileName(content)}' to Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); errorCount++; } } } else if (system == 1) { foreach (string content in psfiles) { Log($"Copying {Path.GetFileName(content)} to Legacy of Solaris (Build: {buildNumber})..."); try { List <string> getFile = Directory.GetFiles(text_GameDirectory.Text, Path.GetFileName(content), SearchOption.AllDirectories).ToList(); string filePath = getFile[0].Remove(0, text_GameDirectory.Text.Length).Substring(1); Directory.CreateDirectory(Path.Combine(buildDir, Path.GetDirectoryName(filePath))); File.Copy(content, Path.Combine(buildDir, filePath), true); } catch { Log($"Failed to copy '{Path.GetFileName(content)}' to Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); errorCount++; } } } if (errorCount == 0) { Log($"Legacy of Solaris (Build: {buildNumber}) was built successfully..."); SystemSounds.Asterisk.Play(); } else { Log($"Failed to build Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); try { if (Directory.Exists(buildDir)) { DirectoryInfo buildData = new DirectoryInfo(buildDir); foreach (FileInfo file in buildData.GetFiles()) { file.Delete(); } foreach (DirectoryInfo directory in buildData.GetDirectories()) { directory.Delete(true); } Directory.Delete(buildDir); } } catch { return; } } InterfaceState(true); } else { Log($"Failed to build Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); UnifyMessages.UnifyMessage.Show("Please specify a valid game directory...", "Path Error", "OK", "Error"); InterfaceState(true); return; } try { if (system == 0) { if (check_ForceParams.Checked) { foreach (string script in pscripts) { File.Move(Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub"), script); } } else { foreach (string script in xscripts) { File.Move(Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub"), script); } } } else if (system == 1) { if (check_ForceParams.Checked) { foreach (string script in xscripts) { File.Move(Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub"), script); } } else { foreach (string script in pscripts) { File.Move(Path.Combine(Path.GetDirectoryName(script), $"{Path.GetFileNameWithoutExtension(script)}.lub"), script); } } } } catch { } } else { Log($"Failed to build Legacy of Solaris (Build: {buildNumber})..."); SystemSounds.Hand.Play(); string invalidRepo = UnifyMessages.UnifyMessage.Show("Invalid repository... Please ensure the selected path is named " + "either 'LoS-Developers' or 'LoS-Developers-master.' If neither " + "exist, do you want to obtain the correct one?", "Repository Error", "YesNo", "Error"); if (invalidRepo == "Yes") { Process.Start("https://github.com/lost-legacy-team/LoS-Developers"); } InterfaceState(true); return; } }
static async Task Main(string[] args) { if (File.Exists("output2.mp4")) { File.Delete("output2.mp4"); } string token = null; using (var client = new HttpClient()) { token = await client.GetStringAsync( "https://spitball-function-dev2.azurewebsites.net/api/studyRoom/code/?code=/Zcx/KGplZt2tX5uh0ljh15eeaqaFBHMqjd9cz4LI0wZTsv4c380gw=="); } var z3 = await "killall Xvfb".Bash(true); //export DISPLAY=\":99\" await "Xvfb :99 -screen 0 1920x1080x24 &".Bash(true); await "xdpyinfo -display :99 >/dev/null 2>&1 && echo \"In use\" || echo \"Free\"".Bash(true); var x = new CancellationTokenSource(); var url = $"https://dev.spitball.co/studyroom/7b0d6988-81ca-40b9-8d70-ac2800cecda6/?token={token}&recordingBot=true"; await "killall chrome".Bash(true); var z4 = await ProcessAsyncHelper.ExecuteShellCommand("google-chrome", new[] { "--remote-debugging-port=9223", "--no-first-run", "--start-fullscreen", "--window-position=0,0", "--window-size=1920,1080", //"--start-maximized", //"--full-screen", "--kiosk", "--disable-gpu", "--enable-logging --v=1", "--no-sandbox", // "--headless", // "--remote-debugging-address=0.0.0.0", url } , CancellationToken.None); var z = await ProcessAsyncHelper.ExecuteShellCommand("ffmpeg", new[] { "-y -nostdin", "-video_size 1920x1080 -framerate 30 -f x11grab", "-draw_mouse 0", "-i :99", "-c:v libx264 -crf 0 -preset ultrafast", "output2.mkv", }, x.Token); await Task.Delay(TimeSpan.FromSeconds(45)); x.Cancel(); var z22222 = await ProcessAsyncHelper.ExecuteShellCommand("ffmpeg", new[] { "-y -nostdin", // "-video_size 1920x1080 -framerate 24 -f x11grab", "-i output2.mkv", "-c:v libx264 -crf 23 -pix_fmt yuv420p", "output2.mp4", }, true, CancellationToken.None); //Create a unique name for the container //string containerName = "quickstartblobs" + Guid.NewGuid().ToString(); // Create the container and return a container client object //BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("spitball-user"); //var blobClient = containerClient.GetBlobClient("test.mp4"); if (File.Exists("output2.mp4")) { await using FileStream uploadFileStream = File.OpenRead("output2.mp4"); Debug.WriteLine(uploadFileStream.Length); //await blobClient.UploadAsync(uploadFileStream, true); uploadFileStream.Close(); } // Process.Start(command); //foreach (var process in Process.GetProcesses()) //{ // Console.WriteLine($"Counter: {process.ProcessName}"); //} var counter = 0; var max = args.Length != 0 ? Convert.ToInt32(args[0]) : -1; while (max == -1 || counter < max) { Console.WriteLine($"Counter: {++counter}"); await Task.Delay(1000); } }