add a quiet flag and some other fixes
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b56c3fe1f6
commit
2fcc7947db
3
chomp.go
3
chomp.go
|
@ -71,6 +71,9 @@ func Chomp(a interface{}) string {
|
||||||
log.Printf("shell.Chomp() FOUND *bytes.Buffer")
|
log.Printf("shell.Chomp() FOUND *bytes.Buffer")
|
||||||
var tmp *bytes.Buffer
|
var tmp *bytes.Buffer
|
||||||
tmp = a.(*bytes.Buffer)
|
tmp = a.(*bytes.Buffer)
|
||||||
|
if (tmp == nil) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
var bytesSplice []byte
|
var bytesSplice []byte
|
||||||
bytesSplice = tmp.Bytes()
|
bytesSplice = tmp.Bytes()
|
||||||
|
|
4
shell.go
4
shell.go
|
@ -44,8 +44,8 @@ func InitCallback(f func(interface{}, int)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// this means it won't copy all the output to STDOUT
|
// this means it won't copy all the output to STDOUT
|
||||||
func Quiet() {
|
func Quiet(q bool) {
|
||||||
quiet = true
|
quiet = q
|
||||||
}
|
}
|
||||||
|
|
||||||
func Script(cmds string) int {
|
func Script(cmds string) int {
|
||||||
|
|
8
wget.go
8
wget.go
|
@ -12,6 +12,8 @@ package shell
|
||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
import "os"
|
import "os"
|
||||||
|
import "fmt"
|
||||||
|
import "log"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
import "strings"
|
import "strings"
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
@ -32,6 +34,12 @@ func Wget(url string) (*bytes.Buffer) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
log.Printf("res.StatusCode: %d\n", resp.StatusCode)
|
||||||
|
if (resp.StatusCode == 404) {
|
||||||
|
handleError(fmt.Errorf("404"), -1)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
buf.ReadFrom(resp.Body)
|
buf.ReadFrom(resp.Body)
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue