2019-06-03 02:20:11 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
2019-06-03 06:57:01 -05:00
|
|
|
// import "fmt"
|
|
|
|
import "time"
|
|
|
|
import "runtime"
|
|
|
|
import "os/exec"
|
|
|
|
import "strings"
|
2019-06-03 02:20:11 -05:00
|
|
|
|
|
|
|
import "git.wit.com/wit/gui"
|
2019-06-06 22:56:14 -05:00
|
|
|
import "git.wit.com/wit/shell"
|
2019-06-03 06:57:01 -05:00
|
|
|
// import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
import "github.com/davecgh/go-spew/spew"
|
2019-06-03 02:20:11 -05:00
|
|
|
|
|
|
|
// import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
func debugClick(b *gui.GuiButton) {
|
|
|
|
log.Println("debugClick() START")
|
|
|
|
gw := b.Box.Window
|
|
|
|
|
2019-06-13 14:08:16 -05:00
|
|
|
box := gui.InitWindow(gw, "Debugging", gui.Yaxis)
|
2019-06-03 20:49:58 -05:00
|
|
|
if (box == nil) { return }
|
2019-06-13 15:09:24 -05:00
|
|
|
gw = box.Window
|
2019-06-13 16:16:29 -05:00
|
|
|
log.Println("debugClick() InitWindow() END")
|
2019-06-03 02:20:11 -05:00
|
|
|
|
2019-06-03 15:03:20 -05:00
|
|
|
makeButton(box, nil, nil, "empty", "SUBDOMAIN", nil)
|
2019-06-03 02:20:11 -05:00
|
|
|
gui.HorizontalBreak(box)
|
|
|
|
makeButton(box, nil, nil, "Create Subdomain Account", "ADD", addSubdomainClick)
|
2019-06-03 20:49:58 -05:00
|
|
|
|
|
|
|
hardXbox := gui.HardBox(box.Window, gui.Xaxis, "subdomain test")
|
2019-06-03 07:32:13 -05:00
|
|
|
Ybox1 := gui.NewBox(hardXbox, gui.Yaxis, "subdomain Y test")
|
|
|
|
Xbox1 := gui.NewBox(Ybox1, gui.Xaxis, "subdomain Y test")
|
|
|
|
makeButton(Xbox1, nil, nil, "ping", "SUBDOMAIN", runPingClick)
|
|
|
|
makeButton(Xbox1, nil, nil, "Cross platform shell test", "SUBDOMAIN", runTestExecClick)
|
2019-06-03 15:03:20 -05:00
|
|
|
makeButton(Xbox1, nil, nil, "empty 3", "SUBDOMAIN", nil)
|
|
|
|
makeButton(Xbox1, nil, nil, "empty 4", "SUBDOMAIN", nil)
|
2019-06-03 06:57:01 -05:00
|
|
|
|
2019-06-03 14:56:20 -05:00
|
|
|
Xbox1 = gui.NewBox(Ybox1, gui.Xaxis, "subdomain Y1 test")
|
|
|
|
makeButton(Xbox1, nil, nil, "List all windows & tabs", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
log.Println("gui.DumpBoxes()")
|
2019-06-04 00:07:15 -05:00
|
|
|
gui.DumpBoxes()
|
2019-06-03 06:57:01 -05:00
|
|
|
})
|
2019-06-03 15:03:20 -05:00
|
|
|
makeButton(Xbox1, nil, nil, "Debug IPv6", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
log.Println("Need to add IPv6 debugging here")
|
|
|
|
})
|
2019-06-05 04:52:35 -05:00
|
|
|
Ybox3 := gui.NewBox(Ybox1, gui.Yaxis, "subdomain Y1 test")
|
|
|
|
gui.NewLabel(Ybox3, "git rev-list: " + config.Gitref)
|
|
|
|
gui.NewLabel(Ybox3, "go build version: " + config.Goversion)
|
2019-06-06 22:56:14 -05:00
|
|
|
gui.NewLabel(Ybox3, "build date: " + shell.Chomp(config.Builddate))
|
2019-06-03 14:56:20 -05:00
|
|
|
|
|
|
|
Ybox2 := gui.NewBox(hardXbox, gui.Yaxis, "subdomain Y test")
|
2019-06-05 12:01:56 -05:00
|
|
|
makeColorButton(Ybox2, nil, nil, "COLOR73", "COLOR73", nil)
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Hide all tabs", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Hide()")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Hide()
|
2019-06-03 02:49:51 -05:00
|
|
|
})
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Hide sleep Show", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Hide()")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Hide()
|
|
|
|
time.Sleep(2000 * time.Millisecond)
|
|
|
|
box.Window.UiTab.Show()
|
|
|
|
})
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Destroy tab 0", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Destroy(0)")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Delete(0)
|
|
|
|
})
|
2019-06-13 15:09:24 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Destroy Splash", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
log.Println("debugClick() Destroy(0)")
|
|
|
|
gui.DeleteWindow("Cloud Accounts")
|
|
|
|
})
|
2019-06-03 02:20:11 -05:00
|
|
|
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Load the default test config file", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
newConfig := loadDefaultConfig()
|
|
|
|
config.Accounts = newConfig.Accounts
|
|
|
|
})
|
|
|
|
makeButton(Ybox2, nil, nil, "runtime.Stack() dump", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
log.Println("\tATTEMPT FULL STACK DUMP")
|
|
|
|
buf := make([]byte, 1<<16)
|
|
|
|
runtime.Stack(buf, true)
|
|
|
|
log.Printf("%s", buf)
|
|
|
|
log.Println("\tFINISHED FULL STACK DUMP")
|
|
|
|
})
|
|
|
|
makeButton(Ybox2, nil, nil, "Close the GUI", "SUBDOMAIN", nil)
|
2019-06-03 02:20:11 -05:00
|
|
|
}
|
2019-06-03 06:57:01 -05:00
|
|
|
|
|
|
|
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
|
2019-06-04 18:14:54 -05:00
|
|
|
tmp = append(tmp, "nohup", "xterm", "-geometry", "120x30", "-e", "ping " + hostname + ";sleep 3")
|
2019-06-03 06:57:01 -05:00
|
|
|
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
|
2019-06-05 04:52:35 -05:00
|
|
|
cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl
|
2019-06-03 06:57:01 -05:00
|
|
|
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")
|
|
|
|
}
|