From 860a026ee00a7b9323c094d7c7f715777fc307eb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 3 Jun 2019 04:57:01 -0700 Subject: [PATCH] flush out a debugging tab Signed-off-by: Jeff Carr --- gui-debug.go | 86 ++++++++++++++++++++++++++++++++++++++++++++++++--- gui-vmPage.go | 63 ------------------------------------- 2 files changed, 82 insertions(+), 67 deletions(-) diff --git a/gui-debug.go b/gui-debug.go index d629d96..485f670 100644 --- a/gui-debug.go +++ b/gui-debug.go @@ -1,8 +1,16 @@ package main import "log" +// import "fmt" +import "time" +import "runtime" +import "os/exec" +import "strings" import "git.wit.com/wit/gui" +// import pb "git.wit.com/wit/witProtobuf" + +import "github.com/davecgh/go-spew/spew" // import "github.com/andlabs/ui" // import _ "github.com/andlabs/ui/winmanifest" @@ -24,11 +32,81 @@ func debugClick(b *gui.GuiButton) { gui.HorizontalBreak(box) makeButton(box, nil, nil, "Create Subdomain Account", "ADD", addSubdomainClick) box = gui.HardBox(gw, gui.Xaxis, "subdomain test") - makeButton(box, nil, nil, "Generate 1", "SUBDOMAIN", nil) - makeButton(box, nil, nil, "Generate 2", "SUBDOMAIN", nil) - makeButton(box, nil, nil, "Generate 3", "SUBDOMAIN", func (*gui.GuiButton) { - log.Println("debugClick() Generate 3") + makeButton(box, nil, nil, "ping", "SUBDOMAIN", runPingClick) + makeButton(box, nil, nil, "Cross platform shell test", "SUBDOMAIN", runTestExecClick) + makeButton(box, nil, nil, "Generate 3", "SUBDOMAIN", nil) + makeButton(box, nil, nil, "Generate 4", "SUBDOMAIN", nil) + + box = gui.NewBox(box, gui.Yaxis, "subdomain Y test") + makeButton(box, nil, nil, "List all windows & tabs", "SUBDOMAIN", func (*gui.GuiButton) { + log.Println("debugClick() Hide()") + box := gw.BoxMap["MAINBOX"] + box.Window.UiTab.Hide() }) + makeButton(box, nil, nil, "Hide all tabs", "SUBDOMAIN", func (*gui.GuiButton) { + log.Println("debugClick() Hide()") + box := gw.BoxMap["MAINBOX"] + box.Window.UiTab.Hide() + }) + makeButton(box, nil, nil, "Hide sleep Show", "SUBDOMAIN", func (*gui.GuiButton) { + log.Println("debugClick() Hide()") + box := gw.BoxMap["MAINBOX"] + box.Window.UiTab.Hide() + time.Sleep(2000 * time.Millisecond) + box.Window.UiTab.Show() + }) + makeButton(box, nil, nil, "Destroy tab 0", "SUBDOMAIN", func (*gui.GuiButton) { + log.Println("debugClick() Destroy(0)") + box := gw.BoxMap["MAINBOX"] + box.Window.UiTab.Delete(0) + }) + makeButton(box, nil, nil, "Generate 76", "SUBDOMAIN", nil) log.Println("debugClick() END box =", box) } + +func runPingClick(b *gui.GuiButton) { + log.Println("runPingClick START") + values, _ := b.Values.(*myButtonInfo) + log.Println("runTestExecClick values.VM", values.VM) + hostname := "localhost" + if (values.VM != nil) { + hostname = values.VM.Hostname + } + spew.Dump(b) + var tmp []string + tmp = append(tmp, "xterm", "-geometry", "120x30", "-e", "ping " + hostname + ";sleep 3") + go runCommand(tmp) + log.Println("runPingClick END") +} + +func runTestExecClick(b *gui.GuiButton) { + log.Println("runTestExecClick START") + if runtime.GOOS == "linux" { + go runSimpleCommand("xterm -report-fonts") + } else if runtime.GOOS == "windows" { + go runSimpleCommand("mintty.exe") + } else { + go runSimpleCommand("xterm") + } + log.Println("runTestExecClick END") +} + +func runSimpleCommand(s string) { + cmd := strings.TrimSpace(s) // this is like 'chomp' in perl + cmdArgs := strings.Fields(cmd) + runCommand(cmdArgs) +} + +func runCommand(cmdArgs []string) { + log.Println("runCommand() START", cmdArgs) + process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...) + // process := exec.Command("xterm", "-e", "ping localhost") + log.Println("runCommand() process.Start()") + process.Start() + log.Println("runCommand() process.Wait()") + process.Wait() + log.Println("runCommand() NEED TO CHECK THE TIME HERE TO SEE IF THIS WORKED") + log.Println("runCommand() OTHERWISE INFORM THE USER") + log.Println("runCommand() END") +} diff --git a/gui-vmPage.go b/gui-vmPage.go index ab99fb1..5f4bc31 100644 --- a/gui-vmPage.go +++ b/gui-vmPage.go @@ -2,15 +2,10 @@ package main import "log" import "fmt" -import "runtime" -import "os/exec" -import "strings" import "git.wit.com/wit/gui" import pb "git.wit.com/wit/witProtobuf" -import "github.com/davecgh/go-spew/spew" - // // THIS IS THE STANDARD VM DISPLAY TABLE // This maps the 'human' indexed cells in the table @@ -138,61 +133,3 @@ func createVmBox(gw *gui.GuiWindow, vm *pb.Event_VM) { makeButton(box, nil, vm, "Save", "SAVE", nil) makeButton(box, nil, vm, "Done", "DONE", nil) } - -func runTestHide(b *gui.GuiButton) { - /* - log.Println("runTestHide START") - Data.Window1.Box1.Hide() - Data.Window1.Box2.Hide() - // time.Sleep(2000 * time.Millisecond) - Data.State = "HIDE" - log.Println("runTestHide END") - */ -} - -func runPingClick(b *gui.GuiButton) { - log.Println("runPingClick START") - values, _ := b.Values.(*myButtonInfo) - log.Println("runTestExecClick values.VM", values.VM) - hostname := "localhost" - if (values.VM != nil) { - hostname = values.VM.Hostname - } - spew.Dump(b) - var tmp []string - tmp = append(tmp, "xterm", "-geometry", "120x30", "-e", "ping " + hostname + ";sleep 3") - go runCommand(tmp) - log.Println("runPingClick END") -} - -func runTestExecClick(b *gui.GuiButton) { - log.Println("runTestExecClick START") - if runtime.GOOS == "linux" { - go runSimpleCommand("xterm -report-fonts") - } else if runtime.GOOS == "windows" { - go runSimpleCommand("mintty.exe") - } else { - go runSimpleCommand("xterm") - } - log.Println("runTestExecClick END") -} - -func runSimpleCommand(s string) { - cmd := strings.TrimSpace(s) // this is like 'chomp' in perl - cmdArgs := strings.Fields(cmd) - runCommand(cmdArgs) -} - -func runCommand(cmdArgs []string) { - log.Println("runCommand() START", cmdArgs) - process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...) - // process := exec.Command("xterm", "-e", "ping localhost") - log.Println("runCommand() process.Start()") - process.Start() - log.Println("runCommand() process.Wait()") - process.Wait() - log.Println("runCommand() NEED TO CHECK THE TIME HERE TO SEE IF THIS WORKED") - log.Println("runCommand() OTHERWISE INFORM THE USER") - log.Println("runCommand() END") -} -