diff options
| author | Jeff Carr <[email protected]> | 2019-06-07 01:15:37 -0700 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2019-06-07 01:15:37 -0700 |
| commit | 2fcc7947db28b2d48e4fcf71a129f615d1e702b5 (patch) | |
| tree | 77b06c4509eddf47e0e1a641164df14edc45c51d | |
| parent | b56c3fe1f6ecd91c771c8a80cca779f1dc6ace8a (diff) | |
add a quiet flag and some other fixes
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | chomp.go | 3 | ||||
| -rw-r--r-- | shell.go | 4 | ||||
| -rw-r--r-- | wget.go | 8 |
3 files changed, 13 insertions, 2 deletions
@@ -71,6 +71,9 @@ func Chomp(a interface{}) string { log.Printf("shell.Chomp() FOUND *bytes.Buffer") var tmp *bytes.Buffer tmp = a.(*bytes.Buffer) + if (tmp == nil) { + return "" + } var bytesSplice []byte bytesSplice = tmp.Bytes() @@ -44,8 +44,8 @@ func InitCallback(f func(interface{}, int)) { } // this means it won't copy all the output to STDOUT -func Quiet() { - quiet = true +func Quiet(q bool) { + quiet = q } func Script(cmds string) int { @@ -12,6 +12,8 @@ package shell import "io" import "os" +import "fmt" +import "log" import "bytes" import "strings" import "net/http" @@ -32,6 +34,12 @@ func Wget(url string) (*bytes.Buffer) { } 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) return buf } |
