GUI: show error windows
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
25fb41e9be
commit
6c5e59073b
5
apt.go
5
apt.go
|
@ -11,13 +11,14 @@ func aptGroup(tab *gui.Node) {
|
|||
n.AddButton("update apt-file", func (*gui.Node) {
|
||||
// shell.Script("apt -y install apt-file\napt-file update")
|
||||
// xterm("apt -y install apt-file; apt-file update")
|
||||
n.ErrorWindow("test error window", "this is the error")
|
||||
// gui.ErrorWindow("test error window", "this is the error")
|
||||
err := sudo( func() error {
|
||||
err := bash("apt install moon-buggy")
|
||||
return err
|
||||
})
|
||||
if (err != nil) {
|
||||
panic("bash failed")
|
||||
gui.ErrorWindow("Error", "Failed to run:\napt install moon-buggy")
|
||||
return
|
||||
}
|
||||
err = bash("bash -x /tmp/jcarr")
|
||||
bash("apt -y install apt-file")
|
||||
|
|
5
os.go
5
os.go
|
@ -8,6 +8,7 @@ import "io/ioutil"
|
|||
import "errors"
|
||||
import "bufio"
|
||||
|
||||
import "git.wit.org/wit/gui"
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
/*
|
||||
|
@ -135,8 +136,10 @@ func bash(cmdline string) error {
|
|||
|
||||
func sudo(f func() error) error {
|
||||
uid := os.Getuid()
|
||||
log.Println("You must be root to do this. uid =", uid)
|
||||
e := "You must be root to do this."
|
||||
log.Println(e, "uid =", uid)
|
||||
if (uid != 0) {
|
||||
gui.ErrorWindow("Permissions Failed", e)
|
||||
return errors.New("not root")
|
||||
}
|
||||
err := f()
|
||||
|
|
|
@ -7,7 +7,7 @@ import "strings"
|
|||
import "errors"
|
||||
import "git.wit.org/wit/gui"
|
||||
|
||||
var filename string = ""
|
||||
var filename string = "resolv-1-1-1-1.conf"
|
||||
|
||||
func resolvWindow(w *gui.Node) {
|
||||
if (w == nil) {
|
||||
|
@ -35,7 +35,7 @@ func resolvWindow(w *gui.Node) {
|
|||
|
||||
resolvNode := gNode.AddComboBox("test", tmp...)
|
||||
|
||||
resolvNode.SetText("resolv-1-1-1-1.conf")
|
||||
resolvNode.SetText(filename)
|
||||
resolvNode.OnChanged = func () {
|
||||
log.Println("STARTED HOSTNAME")
|
||||
filename = resolvNode.GetText()
|
||||
|
|
Loading…
Reference in New Issue