Browse Source

debora+barak updates for downloading

pull/67/head
Jae Kwon 9 years ago
parent
commit
5759ff9b50
2 changed files with 23 additions and 3 deletions
  1. +7
    -0
      cmd/barak/main.go
  2. +16
    -3
      cmd/debora/main.go

+ 7
- 0
cmd/barak/main.go View File

@ -304,6 +304,13 @@ func ServeFile(w http.ResponseWriter, req *http.Request) {
http.Error(w, "Must specify path", 400) http.Error(w, "Must specify path", 400)
return 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) file, err := os.Open(path)
if err != nil { if err != nil {
http.Error(w, Fmt("Error opening file: %v. %v", path, err), 400) http.Error(w, Fmt("Error opening file: %v. %v", path, err), 400)


+ 16
- 3
cmd/debora/main.go View File

@ -4,7 +4,10 @@ import (
"fmt" "fmt"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"io/ioutil" "io/ioutil"
"net/url"
"os" "os"
"regexp"
"strings"
"sync" "sync"
acm "github.com/tendermint/tendermint/account" acm "github.com/tendermint/tendermint/account"
@ -13,6 +16,15 @@ import (
. "github.com/tendermint/tendermint/common" . "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 { var Config = struct {
Remotes []string Remotes []string
PrivKey acm.PrivKey PrivKey acm.PrivKey
@ -212,7 +224,7 @@ func cliListProcesses(c *cli.Context) {
} else { } else {
fmt.Printf("%v processes:\n", Blue(remote)) fmt.Printf("%v processes:\n", Blue(remote))
for _, proc := range response.Processes { 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()) fmt.Printf(" started at %v", proc.StartTime.String())
if proc.EndTime.IsZero() { if proc.EndTime.IsZero() {
fmt.Printf(", running still\n") fmt.Printf(", running still\n")
@ -238,8 +250,9 @@ func cliDownloadFile(c *cli.Context) {
command := btypes.CommandServeFile{ command := btypes.CommandServeFile{
Path: remotePath, Path: remotePath,
} }
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
for i, remote := range Config.Remotes {
for _, remote := range Config.Remotes {
wg.Add(1) wg.Add(1)
go func(remote string, localPath string) { go func(remote string, localPath string) {
defer wg.Done() defer wg.Done()
@ -249,7 +262,7 @@ func cliDownloadFile(c *cli.Context) {
} else { } else {
fmt.Printf("%v success. Wrote %v bytes to %v\n", remote, n, localPath) 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() wg.Wait()
} }

Loading…
Cancel
Save