diff --git a/cmd/barak/main.go b/cmd/barak/main.go index d11a0c720..9f28de78b 100644 --- a/cmd/barak/main.go +++ b/cmd/barak/main.go @@ -304,6 +304,13 @@ func ServeFile(w http.ResponseWriter, req *http.Request) { http.Error(w, "Must specify path", 400) return } + if path[0] == '.' { + // local paths must be explicitly local, e.g. "./xyz" + } else if path[0] != '/' { + // If not an absolute path, then is label + proc := barak.processes[path] + path = proc.OutputPath + } file, err := os.Open(path) if err != nil { http.Error(w, Fmt("Error opening file: %v. %v", path, err), 400) diff --git a/cmd/debora/main.go b/cmd/debora/main.go index de1459979..0343348a7 100644 --- a/cmd/debora/main.go +++ b/cmd/debora/main.go @@ -4,7 +4,10 @@ import ( "fmt" "github.com/codegangsta/cli" "io/ioutil" + "net/url" "os" + "regexp" + "strings" "sync" acm "github.com/tendermint/tendermint/account" @@ -13,6 +16,15 @@ import ( . "github.com/tendermint/tendermint/common" ) +func remoteNick(remote string) string { + u, err := url.Parse(remote) + if err != nil { + return regexp.MustCompile(`[[:^alnum:]]`).ReplaceAllString(remote, "_") + } else { + return regexp.MustCompile(`[[:^alnum:]]`).ReplaceAllString(u.Host, "_") + } +} + var Config = struct { Remotes []string PrivKey acm.PrivKey @@ -212,7 +224,7 @@ func cliListProcesses(c *cli.Context) { } else { fmt.Printf("%v processes:\n", Blue(remote)) for _, proc := range response.Processes { - fmt.Printf(" \"%v\" => `%v %v` (%v)\n", Yellow(proc.Label), proc.ExecPath, proc.Args, proc.Pid) + fmt.Printf(" \"%v\" => `%v %v` (%v)\n", Yellow(proc.Label), proc.ExecPath, strings.Join(proc.Args, ","), proc.Pid) fmt.Printf(" started at %v", proc.StartTime.String()) if proc.EndTime.IsZero() { fmt.Printf(", running still\n") @@ -238,8 +250,9 @@ func cliDownloadFile(c *cli.Context) { command := btypes.CommandServeFile{ Path: remotePath, } + wg := sync.WaitGroup{} - for i, remote := range Config.Remotes { + for _, remote := range Config.Remotes { wg.Add(1) go func(remote string, localPath string) { defer wg.Done() @@ -249,7 +262,7 @@ func cliDownloadFile(c *cli.Context) { } else { fmt.Printf("%v success. Wrote %v bytes to %v\n", remote, n, localPath) } - }(remote, Fmt("%v_%v", localPathPrefix, i)) + }(remote, Fmt("%v_%v", localPathPrefix, remoteNick(remote))) } wg.Wait() }