public static LsViewsInfo LoadLsViewInfos() { var lines = CommandLineExecutor.ExecuteCleartool($"lsview -host {Environment.MachineName} -quick -long") .Split(new[] { "\r\n" }, StringSplitOptions.None) .Where(x => x.StartsWith("View server access path:") || x.StartsWith("View uuid:")) .ToArray(); var viewBaseDir = lines.Any() ? lines.First(x => x.StartsWith("View server access path:")).Split(new[] { ": " }, StringSplitOptions.RemoveEmptyEntries)[1].Get(x => { var slashCount = x.Count(c => c == '\\'); var slashNumberToGet = slashCount - 3; var slashIndex = x.Aggregate(new { Index = 0, Slashes = 0, Result = -1 }, (r, c) => new { Index = r.Index + 1, Slashes = c == '\\' ? r.Slashes + 1 : r.Slashes, Result = r.Slashes == slashNumberToGet - 1 && c == '\\' ? r.Index : r.Result }, r => r.Result); var localPath = x.Substring(0, slashIndex); var networkPath = $@"\\{Constants.HostName}\{Path.GetFileName(localPath)}"; return(new ViewsBaseDirectory(localPath, networkPath)); }) : Constants.BaseDirIfNoViews; var views = lines.Batch(2).Select(x => new LsViewInfo ( x.First().Split(new[] { ": " }, StringSplitOptions.RemoveEmptyEntries)[1], x.Skip(1).First().Split(new[] { ": " }, StringSplitOptions.RemoveEmptyEntries)[1] )).ToArray(); return(new LsViewsInfo(viewBaseDir, views)); }
public void ShouldExecuteMoreLinesBySpecifiedInputAndOutput() { var commandLine = String.Join(Environment.NewLine, "PLACE 2,2,NORTH", "REPORT", "MOVE", "LEFT", "REPORT", "MOVE", "REPORT", "RIGHT", "REPORT"); var input = new StringReader(commandLine); var outputContent = new StringBuilder(); var output = new StringWriter(outputContent); CommandLineExecutor.Execute(input, output); var outputs = new[] { "2,2,NORTH", "2,3,WEST", "1,3,WEST", "1,3,NORTH" }; var expectedOutput = String.Join(Environment.NewLine, outputs) + Environment.NewLine; Assert.Equal(expectedOutput, outputContent.ToString()); }
public void LocalBashCmdLineDictifyClasses() { var rootFile = TestUtils.CreateFileOfInt(20); // Load up an extra dictionary ntuple._gClassesToDeclare = new[] { "vector<vector<vector<float>>>" }; ntuple._gClassesToDeclareIncludes = new[] { "vector" }; // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Where(r => LocalBashCmdLineDictifyClassesHelpers.DoDictDump() > 0).Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsLocalBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CleanupQuery = false; bool seenTDataType = false; CommandLineExecutor.AddLogEndpoint(s => { seenTDataType |= s.Contains("TDataType"); Console.WriteLine(s); }); int result = exe.ExecuteScalar <int>(query); Assert.IsTrue(seenTDataType); }
/// <summary> /// Run a simple test that looks for errors and warnings /// </summary> /// <param name="configureMe"></param> private static void RunSimpleTestForErrorsAndWarnings(Action <TTreeQueryExecutor> configureMe) { var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); configureMe(exe); // Look for warning or error var errorLines = new List <string>(); CommandLineExecutor.AddLogEndpoint(s => { if (s.ToLower().Contains("warning") || s.ToLower().Contains("error")) { errorLines.Add(s); } }); int result = exe.ExecuteScalar <int>(query); foreach (var l in errorLines) { Console.WriteLine("************ Contains error or warning: " + l); } Assert.AreEqual(0, errorLines.Count, "See std out for list of error liens"); }
public static void ApplyCs(string[] cs, string localViewPath) { var sw = Stopwatch.StartNew(); var cfgFile = $@"{localViewPath}\cs.cfg"; Directory.SetCurrentDirectory(localViewPath); File.WriteAllLines(Constants.TempCsStorageFileName, cs); var srcElapsed = TimeSpan.Zero; var relElapsed = TimeSpan.Zero; Parallel.Invoke(() => { var i = 0; CommandLineExecutor.ExecuteCleartool(new[] { $"setcs -force {Constants.TempCsStorageFileName}" }, o => o.Subscribe(s => Console.Write(++i % 2000 == 0 ? "]" : i % 1000 == 0 ? "[" : string.Empty))); srcElapsed = sw.Elapsed; Console.WriteLine($"Source files updated. Elapsed: {srcElapsed}."); }, () => { ProcessRelVobsRules(cs, localViewPath); relElapsed = sw.Elapsed; Console.WriteLine($"Rel vob files updated. Elapsed: {relElapsed}."); File.WriteAllLines(cfgFile, cs); }); sw.Stop(); Console.WriteLine($"Update done.\r\nSource: {srcElapsed}.\r\nRel: {relElapsed}."); }
static void Main(string[] args) { try { Console.WriteLine("RTG E-RIN Compiler version 0.1"); Console.WriteLine("Copyright RTG 2004 All rights reserved"); Console.WriteLine(); CommandLineExecutor cle = new CommandLineExecutor(); if (cle.ParseCommandLine(args)) { cle.CompileAndExecute(); } else return; // cle.Compile(); // cle.Execute(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public void ShouldExecutePlaceBySpecifiedInputAndOutput() { var commandLine = "PLACE 1,2,NORTH"; var input = new StringReader(commandLine); var output = new StringWriter(); CommandLineExecutor.Execute(input, output); }
// Clear temp data private void ClearTempData() { // execute command cmdExecutor = new CommandLineExecutor(); command = "conda activate & set PYTHONIOENCODING=UTF-8 &" + " python ..\\..\\..\\..\\DBUIScripts\\tempData_clear.py"; cmdExecutor.ExecuteCommandSync(command); }
public static string[] GetBldCs(ProductId product, TargetVersion target, string build) { var output = CommandLineExecutor.ExecuteCmd(GetBldCsCommandText(product, target, build)); return(output.Split(new[] { "\r\n" }, StringSplitOptions.None) .SkipUntil(x => x.Contains(Constants.GetBldCsScriptFileName)) .TakeWhile(x => !x.EndsWith(">exit")) .Select(x => x.Replace("# stgsrvload", "#stgsrvload")) .ToArray()); }
private void btnUpdate_Click(object sender, EventArgs e) { // check if input elements are sufficient switch (cbActivateMethod.SelectedIndex) { case 0: tbActivateValue.Text = "0"; break; case 1: try { Convert.ToInt32(tbActivateValue.Text); } catch (System.FormatException) { MessageBox.Show("輸入數值必須為數字!"); return; } break; case 2: try { Convert.ToInt32(tbActivateValue.Text); } catch (System.FormatException) { MessageBox.Show("輸入數值必須為數字!"); return; } break; } string[] names = rtUpdate.Text.Split(','); if (names.Length < 1) { MessageBox.Show("您必須至少書入一個名字才能使用生效功能!"); return; } for (int nameIndex = 0; nameIndex < names.Length; nameIndex++) { cmdExecutor = new CommandLineExecutor(); command = "conda activate & set PYTHONIOENCODING=UTF-8 &" + " python ..\\..\\..\\..\\DBUIScripts\\db_update.py " + names[nameIndex] + " " + cbActivateType.SelectedIndex.ToString() + " " + cbActivateMethod.SelectedIndex.ToString() + " " + tbActivateValue.Text.ToString(); Console.WriteLine(command); cmdExecutor.ExecuteCommandSync(command); } MessageBox.Show("更新點數完成,若確認結果請重新執行點數查詢。"); }
private void btnBatchUpload_Click(object sender, EventArgs e) { if (fbdBatchUpload.SelectedPath == "") { MessageBox.Show("您未選取批次建檔資料夾"); return; } string[] files = Directory.GetFiles(batchUplaadReadInPath); ClearTempData(); // iterate all files and create csv document inside temp folder for (int i = 0; i < files.Length; i++) { LinkExcelToDGV(dgvBatchUpload, files[i]); // revise datetime column to desired format (dgv) for (int gridIndex = 0; gridIndex < dgvBatchUpload.Rows.Count; gridIndex++) { try { int addingDate = Convert.ToInt32(dgvBatchUpload.Rows[gridIndex].Cells[4].Value); DateTime date = new DateTime(1900, 1, 1); date = date.AddDays(addingDate - 2); dgvBatchUpload.Rows[gridIndex].Cells[4].Value = date.ToShortDateString(); } catch (System.FormatException) { } } // save as csv file in temp dir // write to csv from data grid view fileNameItself = files[i].Split('\\').Last().Split('.')[0] + ".csv"; string projDir = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName; string outputFileName = System.IO.Path.Combine(projDir, @".\temp\", fileNameItself); ExportDGVToCSV(dgvBatchUpload, outputFileName); // close excel app CloseExcelAPP(); } // start uploading files into database cmdExecutor = new CommandLineExecutor(); command = "conda activate & set PYTHONIOENCODING=UTF-8 &" + " python ..\\..\\..\\..\\DBUIScripts\\batch_upload.py "; Console.WriteLine(command); cmdExecutor.ExecuteCommandSync(command); MessageBox.Show("批次建檔完成"); }
public void ShouldExecuteMultipleLinesBySpecifiedInputAndOutput() { var commandLine = String.Join(Environment.NewLine, "PLACE 1,2,NORTH", "REPORT"); var input = new StringReader(commandLine); var outputContent = new StringBuilder(); var output = new StringWriter(outputContent); CommandLineExecutor.Execute(input, output); Assert.Equal("1,2,NORTH" + Environment.NewLine, outputContent.ToString()); }
public void ShouldIgnoreInvalidCommands() { var commandLine = String.Join(Environment.NewLine, "PLACE 1,2,NORTH", "MOVEOUT", "REPORT"); var input = new StringReader(commandLine); var outputContent = new StringBuilder(); var output = new StringWriter(outputContent); CommandLineExecutor.Execute(input, output); Assert.Equal("1,2,NORTH" + Environment.NewLine, outputContent.ToString()); }
public static string[] GetChangelist(View view) { var fcmd = $@"cleartool find {view.ProductId.Name} -all -ele ""brtype({view.SrBranchName.Value})"" -exec ""cleartool descr -fmt \""%En\n\"" \""%CLEARCASE_PN%\"""""; var directory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(view.ViewRoot.LocalPath); var files = CommandLineExecutor .ExecuteCmd(fcmd) .Split('\n') .SkipWhile(x => !x.Contains(">cleartool find")) .Skip(1) .TakeWhile(x => !x.Contains(">exit")) .Where(x => !string.IsNullOrEmpty(x.Trim())) .Select(x => x.Replace(view.ViewRoot.LocalPath, string.Empty).Replace("\r", string.Empty)) .ToArray(); Directory.SetCurrentDirectory(directory); return(files); }
public void RemoteBashCmdLineCheckDebugDumps() { // When we run in debug mode, make sure the command line dumps are there. var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); // Capture the lines bool seenCacheInfo = false; CommandLineExecutor.AddLogEndpoint(s => seenCacheInfo |= s.ToLower().Contains("cache")); exe.CompileDebug = true; int result = exe.ExecuteScalar <int>(query); Assert.IsTrue(seenCacheInfo); }
public static View LoadView(string directory) { var wdv = CommandLineExecutor.ExecuteCleartool("pwv -wdview") .Replace("Working directory view: ", string.Empty) .Trim(); if (wdv.Contains("** NONE")) { return(null); } var localRoot = CommandLineExecutor.ExecuteCleartool("pwv -root").Trim(); var stgPath = CommandLineExecutor.ExecuteCleartool($"lsview {wdv}").Split(' ').Last().Trim(); var root = new ViewRoot(localRoot, stgPath); var cs = root?.GetConfigSpec(); var type = cs?.GetViewType(); var view = type == null?View.Unknown(root, cs) : type.Value == ViewType.Sr ? View.Sr(root, cs, cs.GetProductId(), cs.GetTargetVersion(), cs.GetSrBranchName()) : type.Value == ViewType.Build ? View.Bld(root, cs, cs.GetProductId(), cs.GetTargetVersion(), cs.GetBuild()) : null; return(view); }
public void TestSimpleExecuteDifferentProcess() { var result = CommandLineExecutor.ExecuteCleartool("lsview -host HS7PW12 -quick -long"); Console.WriteLine(result); }
private void btnDataUpload_Click(object sender, EventArgs e) { // check if data upload information is sufficient if (cbOtherSeries.Checked == true && tbSeriesName.Text.Length == 0) { MessageBox.Show("您已選擇其他場次系列,但並未輸入該系列名稱!!!"); return; } else if (tbActivityName.Text.Length == 0) { MessageBox.Show("您並未輸入場次名稱!!!"); return; } else if (tbActivityDate.Text.Length != 8) { MessageBox.Show("您輸入的日期格式長度不正確!!!"); return; } else if (tbSemester.Text.Length != 5 || tbSemester.Text.Split('-')[0].Length != 3 || tbSemester.Text.Split('-')[1].Length != 1) { MessageBox.Show("您輸入的學期格式長度不正確!!!"); return; } else if (dlgOpenDataUpload.FileName == "openFileDialog1") { MessageBox.Show("您並未選擇要處理的檔案!!!"); return; } else if (fbdDataUpload.SelectedPath == "") { MessageBox.Show("您並未選擇欲輸出至的檔案資料夾!!!"); return; } string seriesName; if (cbOtherSeries.Checked == true) { seriesName = tbSeriesName.Text; } else { seriesName = cbActivitySeries.SelectedItem.ToString(); } // execute python script and start data constructing process cmdExecutor = new CommandLineExecutor(); command = "conda activate & set PYTHONIOENCODING=UTF-8 &" + " python ..\\..\\..\\..\\DBUIScripts\\data_construct.py " + fileNameItself + " " + seriesName + " " + tbActivityName.Text + " " + tbActivityDate.Text + " " + tbSemester.Text + " " + fbdDataUpload.SelectedPath + "\\"; Console.WriteLine(command); cmdExecutor.ExecuteCommandSync(command); MessageBox.Show("資料處理並上傳資料庫完成!"); }
private void btnSearch_Click(object sender, EventArgs e) { string searchType = ""; string searchElement = ""; string searchContent = tbSearchContent.Text; string ifExport = ""; string projDir = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName; string exportPath = System.IO.Path.Combine(projDir, @"temp\blacklist_search.xlsx"); switch (cbSearchType.SelectedIndex) { case 0: searchType = "0"; break; case 1: searchType = "1"; break; } // check if input element is sufficient switch (cbSearchMethod.SelectedIndex) { case 0: try { Convert.ToInt32(tbSearchContent.Text); searchElement = "0"; } catch (System.FormatException Exception) { MessageBox.Show("使用次數查詢時,\n您所輸入的搜尋條件必須為數字!!!"); return; } break; case 1: if (tbSearchContent.Text.Length == 0) { MessageBox.Show("您必須輸入搜尋條件!!!"); } searchElement = "1"; break; case 2: if (tbSearchContent.Text.Length == 0) { MessageBox.Show("您必須輸入搜尋條件!!!"); } searchElement = "2"; break; } if (cbBlackListSerachIfOutput.Checked == true && fbdPointSearch.SelectedPath == "") { MessageBox.Show("您未選取輸出資料夾路徑!!!"); return; } ClearTempData(); //// execute python script and start data constructing process cmdExecutor = new CommandLineExecutor(); if (cbBlackListSerachIfOutput.Checked == true) { exportPath = blackListSearchSaveAsPath; ifExport = "1"; command = "conda activate & set PYTHONIOENCODING=UTF-8 &" + " python ..\\..\\..\\..\\DBUIScripts\\black_list_search.py " + searchType + " " + searchElement + " " + searchContent + " " + ifExport + " " + exportPath + "\\"; } else { ifExport = "0"; command = "conda activate & set PYTHONIOENCODING=UTF-8 &" + " python ..\\..\\..\\..\\DBUIScripts\\black_list_search.py " + searchType + " " + searchElement + " " + searchContent + " " + ifExport + " " + exportPath; } Console.WriteLine(command); cmdExecutor.ExecuteCommandSync(command); // show query result in datagrid // link excel to data grid view try { if (ifExport == "1") { LinkExcelToDGV(dgvSearch, exportPath + "\\blacklist_search.xlsx"); } else { LinkExcelToDGV(dgvSearch, exportPath); } } catch (System.Runtime.InteropServices.COMException Exception) { MessageBox.Show("錯誤發生,聯絡 Ricardo"); return; } MessageBox.Show("查詢完成"); }
static void Main(string[] args) { var folder = Environment.CurrentDirectory; var view = folder.GetCurrentView(); var cmd = args.FirstOrDefault(); if (cmd == Commands.ConfigSpec) { var productId = new ProductId(args[1]); var targetVersion = new TargetVersion(args[2]); var branch = "jsrXXXXXX_VC"; var cs = MainApi.GetSrCsWeb(productId, targetVersion, branch); cs.ForEach(line => Console.WriteLine(line)); } else if (cmd == Commands.LoadRelVobs) { var productId = new ProductId(args[1]); var targetVersion = new TargetVersion(args[2]); var branch = "jsrXXXXXX_VC"; var localViewPath = Directory.GetParent(folder).FullName; if (!Directory.Exists(Path.Combine(folder, "Products"))) { Console.WriteLine("Directory does not appear to be a view main VOB directory. Please type YES if you force to continue."); if (Console.ReadLine().ToUpper() != "YES") { return; } } var cs = MainApi.GetSrCsWeb(productId, targetVersion, branch); cs.ForEach(line => Console.WriteLine(line)); MainApi.ApplyCs(cs, localViewPath); } else if (cmd != Commands.Cd) { Console.WriteLine(view?.DisplayText ?? $"{folder} is not ClearCase view path"); } var canOperateOnNonCcViews = args.Length > 3 && cmd.IsOneOf(Commands.NewSr, Commands.NewBuild); if (!canOperateOnNonCcViews && (!args.Any() || view?.ViewType == null || view.ViewType.Value != ViewType.Sr)) { return; } if (cmd == Commands.Help) { var commands = typeof(Commands) .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) .Where(x => x.IsLiteral && !x.IsInitOnly) .Select(x => (string)x.GetRawConstantValue()) .ToArray(); Console.WriteLine("These commands are defined:"); Console.WriteLine(commands.ToLinesString()); } else if (cmd == Commands.FullUpdate) { Console.WriteLine("Getting latest config spec from css..."); var cs = MainApi.GetSrCsWeb(view); Console.WriteLine("Applying config spec..."); MainApi.ApplyCs(cs, view.ViewRoot.LocalPath); } else if (cmd == Commands.FullUpdateGit) { var gitDir = Directory.GetCurrentDirectory(); Console.WriteLine("Getting latest config spec from css..."); var cs = MainApi.GetSrCsWeb(view); Console.WriteLine("Applying config spec..."); MainApi.ApplyCs(cs, view.ViewRoot.LocalPath); Console.WriteLine("Syncing with git..."); Directory.SetCurrentDirectory(gitDir); var i = 0; var log = CommandLineExecutor.ExecuteCmd(@"python ""c:\bin2\git-cc-master\gitcc"" update sync", o => o.Subscribe(s => Console.Write(++i % 2000 == 0 ? ">" : i % 1000 == 0 ? "<" : string.Empty))); Console.WriteLine(log); } else if (cmd == Commands.ApplyCs) { var cs = view.ConfigSpec.Lines; Console.WriteLine("Applying config spec..."); MainApi.ApplyCs(cs, view.ViewRoot.LocalPath); } else if (cmd == Commands.ShowChangelist) { MainApi.GetChangelist(view).ForEach(x => Console.WriteLine(x)); } else if (cmd == Commands.NewSr) { var branch = args[1]; var productId = args.Length > 3 ? new ProductId(args[2]) : view.ProductId; var targetVersion = args.Length > 3 ? new TargetVersion(args[3]) : view.TargetVersion; if (view == null) { var viewDirName = args.Length > 4 ? args[4] : string.Empty; Console.WriteLine("Preparing new view environment..."); var currentDir = Directory.GetCurrentDirectory(); var tag = $"{Environment.MachineName}_{viewDirName}"; var baseDir = new ViewsBaseDirectory($"{currentDir}", $"\\\\{Environment.MachineName}\\{Path.GetFileName(currentDir)}"); var networkViewPath = Path.Combine(baseDir.NetworkPath, viewDirName); var localViewPath = Path.Combine(baseDir.LocalPath, viewDirName); Console.WriteLine($"currentDir = {currentDir}"); Console.WriteLine($"viewDirName = {viewDirName}"); Console.WriteLine($"tag = {tag}"); Console.WriteLine($"baseDir.NetworkPath = {baseDir.NetworkPath}"); Console.WriteLine($"baseDir.LocalPath = {baseDir.LocalPath}"); Console.WriteLine($"networkViewPath = {networkViewPath}"); Console.WriteLine($"localViewPath = {localViewPath}"); Console.WriteLine("Creating new view..."); CommandLineExecutor.ExecuteCleartool($"mkview -snapshot -tag {tag} \"{networkViewPath}\""); Directory.SetCurrentDirectory(localViewPath); view = folder.GetCurrentView(); } Console.WriteLine("Loading config spec..."); var cs = MainApi.GetSrCsWeb(productId, targetVersion, branch); var makeBranch = !branch.ToLower().Contains("xxx"); if (makeBranch) { var productToBranch = cs.FirstOrDefault(line => line.StartsWith("# Product: "))?.Trim().Split(' ').LastOrDefault() ?? productId.Name; Console.WriteLine($"Making branch {branch} for product {productToBranch}..."); CommandLineExecutor.ExecuteCleartool($@"mkbrtype -c . {branch}@\{productToBranch}"); } Console.WriteLine("Applying config spec..."); MainApi.ApplyCs(cs, view.ViewRoot.LocalPath); } else if (cmd == Commands.NewBuild) { var productId = new ProductId(args[1]); var targetVersion = new TargetVersion(args[2]); var build = args[3]; if (view == null) { var viewDirName = build; Console.WriteLine("Preparing new view environment..."); var currentDir = Directory.GetCurrentDirectory(); var tag = $"{Environment.MachineName}_{viewDirName}"; var baseDir = new ViewsBaseDirectory($"{currentDir}", $"\\\\{Environment.MachineName}\\{Path.GetFileName(currentDir)}"); var networkViewPath = Path.Combine(baseDir.NetworkPath, viewDirName); var localViewPath = Path.Combine(baseDir.LocalPath, viewDirName); Console.WriteLine($"currentDir = {currentDir}"); Console.WriteLine($"viewDirName = {viewDirName}"); Console.WriteLine($"tag = {tag}"); Console.WriteLine($"baseDir.NetworkPath = {baseDir.NetworkPath}"); Console.WriteLine($"baseDir.LocalPath = {baseDir.LocalPath}"); Console.WriteLine($"networkViewPath = {networkViewPath}"); Console.WriteLine($"localViewPath = {localViewPath}"); Console.WriteLine("Creating new view..."); CommandLineExecutor.ExecuteCleartool($"mkview -snapshot -tag {tag} \"{networkViewPath}\""); Directory.SetCurrentDirectory(localViewPath); view = folder.GetCurrentView(); } Console.WriteLine("Loading config spec..."); var cs = MainApi.GetBldCsWeb(productId, targetVersion, build); Console.WriteLine("Applying config spec..."); MainApi.ApplyCs(cs, view.ViewRoot.LocalPath); } else if (cmd == Commands.MergeToRemote) { Console.WriteLine("Getting changelist..."); var files = MainApi.GetChangelist(view); var filesCut = files.Where(x => !files.Any(dir => x != dir && x.Contains(dir))).ToArray(); filesCut.ForEach(x => Console.WriteLine(x)); var to = args.Length > 1 ? args[1] : "mrg_latest"; Process.Start("clearmrgman", $@"/t {to} /b {view.SrBranchName.Value} /n {string.Join(" ", filesCut)}"); } else if (cmd == Commands.MergeToRemoteSlow) { var to = args.Length > 1 ? args[1] : "mrg_latest"; Process.Start("clearmrgman", $@"/t {to} /b {view.SrBranchName.Value}"); } else if (cmd == Commands.MergeFromRemote) { var from = args.Length > 1 ? args[1] : "main"; Process.Start("clearmrgman", $@"/t {view.ViewRoot.LocalPath} /f {from} /n \{view.ProductId.Name}"); } else if (cmd == Commands.OpenBrtool) { Process.Start("brtool", $@"{view.SrBranchName.Value}"); } else if (cmd == Commands.ShowVersionTree) { var fileName = args[1]; var fullFileName = Path.Combine(folder.Replace(".git", string.Empty), fileName); Process.Start("clearvtree", $@"{fullFileName}"); } else if (cmd == Commands.OpenJira) { if (view.SrBranchName.Value.StartsWith("jsr")) { Process.Start("chrome.exe", $@"http://sc-css-devjira/jira/browse/SR-{view.SrBranchName.Value.Substring(3)}"); } } else if (cmd == Commands.ShowHistory) { var fileName = args[1]; var fullFileName = Path.Combine(folder.Replace(".git", string.Empty), fileName); CommandLineExecutor.ExecuteCleartool($"lshistory -graphical {fullFileName}"); } else if (cmd == Commands.Cd) { var fileName = args[1]; var fullFileName = Path.Combine(folder.Replace(".git", string.Empty), fileName); var dir = Path.GetDirectoryName(fullFileName); Clipboard.SetText($"cd {dir}"); } else if (cmd == Commands.Annotate) { var fileName = args[1]; var fullFileName = Path.Combine(folder.Replace(".git", string.Empty), fileName); CommandLineExecutor.ExecuteCleartool($"annotate {fullFileName}"); Process.Start($"{fullFileName}.ann"); } else if (cmd == Commands.CheckinToClearCase) { CommandLineExecutor.ExecuteCmd(new[] { @"git add -A", @"git commit -m ""none""", @"gitcc checkin" }, o => o.Subscribe(Console.Write)); } else { Console.WriteLine("Unknown command: {0}", cmd); } }
static void Main(string[] args) { var result = CommandLineExecutor.ExecuteCleartool("lsview -host HS7PW12 -quick -long"); Console.WriteLine(result); }
public void TestCleanup() { TestUtils.ResetLINQLibrary(); MEFUtilities.MyClassDone(); CommandLineExecutor.ResetCommandLineExecutor(); }
public void TestSimpleExecute() { var result = CommandLineExecutor.ExecuteCmd("ipconfig"); Console.WriteLine(result); }
private void HandleConsoleCommand(Messages.ConsoleCommand consoleCommandMsg) { var args = ProcessCommand(consoleCommandMsg.Command); CommandLineExecutor.InvokeCommand(args, typeof(ChatClientCoordinatorActor)); }
internal static void ProcessRelVobsRules(string[] cs, string localViewPath) { var cfgFile = $@"{localViewPath}\cs.cfg"; var curRules = GetRulesMapFromCs(File.Exists(cfgFile) ? File.ReadAllLines(cfgFile) : new string[0]); var newRules = GetRulesMapFromCs(cs); var rules = newRules.Select(rule => new { SrcRootPath = rule.Key, Items = rule.Value, Match = curRules.GetOrNull(rule.Key)?.SequenceEqual(rule.Value) ?? false }).ToArray(); try { var unmatchedCount = rules.Where(x => !x.Match).Aggregate(0, (x, acc) => x + acc.Items.Length); if (unmatchedCount > 0) { Console.WriteLine($"Cleaning {unmatchedCount} rel directories..."); var log = new StringBuilder(); rules.Where(x => !x.Match).ForEach(rule => rule.Items.ForEach(srcSubPath => { var subPathRootDir = srcSubPath.Split('/')[0]; var dstSubPathRootDir = $@"{localViewPath}\{subPathRootDir}"; FileSystemUtils.FastCleanDir(dstSubPathRootDir, Observer.Create <string>(s => log.Append(s))); })); Console.WriteLine(log.ToString()); Console.WriteLine($"Copying {unmatchedCount} rel directories..."); var done = 0; rules.Where(x => !x.Match).SelectMany(rule => rule.Items.SelectMany ( srcSubPath => { var isTlbx = srcSubPath == "tlbx"; if (isTlbx) { var subDirs = Directory.GetDirectories($@"{rule.SrcRootPath}\tlbx"); var subFiles = Directory.GetFiles($@"{rule.SrcRootPath}\tlbx"); unmatchedCount += subDirs.Length + subFiles.Length - 1; var result = subDirs.Concat(subFiles).SelectArray(srcSubPathTlbx => new { rule.SrcRootPath, srcSubPath = srcSubPathTlbx.Substring(rule.SrcRootPath.Length + 1).Replace('\\', '/') }); return(result); } return(new { rule.SrcRootPath, srcSubPath }.Unfold()); } )).AsParallel().WithDegreeOfParallelism(100).ForAll(x => { var srcRootPath = x.SrcRootPath; var srcSubPath = x.srcSubPath; var zipFile = Directory.Exists(srcRootPath) ? Directory.GetFiles($@"{srcRootPath}\{srcSubPath.Split('/')[0]}", $"{srcSubPath.Split('/')[0]}.zip").SingleOrDefault() : null; var extract = zipFile != null && !Directory.GetDirectories($@"{srcRootPath}\{srcSubPath.Split('/')[0]}").Any(); if (extract) { using (var archive = ZipFile.OpenRead(zipFile)) { archive.ExtractToDirectory(localViewPath, true); } } else { var fromPath = $@"{srcRootPath}\{srcSubPath.Replace('/', '\\')}"; var toPath = $@"{localViewPath}\{srcSubPath.Replace('/', '\\')}"; var isFromPathDirectory = File.GetAttributes(fromPath).HasFlag(FileAttributes.Directory); var from = isFromPathDirectory ? fromPath : Path.GetDirectoryName(fromPath); var to = isFromPathDirectory ? $@"{toPath}\" : $@"{Path.GetDirectoryName(toPath)}\"; var file = isFromPathDirectory ? string.Empty : Path.GetFileName(fromPath); var zipFileToken = zipFile == null ? string.Empty : $@"/xf {zipFile} "; var roboCommand = $@"robocopy {from} {to} {file} /e {zipFileToken}/NFL /NDL /NJS /NJH /nc /ns /np"; CommandLineExecutor.ExecuteCmd(roboCommand.Unfold(), o => o.Subscribe(s => { })); } var remaining = unmatchedCount - Interlocked.Increment(ref done); Console.WriteLine(extract ? $"Extracted {Path.GetFileName(zipFile)} ({remaining})." : $"Copied {srcSubPath} ({remaining})."); }); } } finally { if (File.Exists(cfgFile)) { File.Delete(cfgFile); } File.WriteAllLines(cfgFile, cs); } }