Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Side by Side Diff: dm/tools/dmtool/vizQuery.go

Issue 2227113002: Update bulidbucket client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dm/appengine/distributor/jobsim/run.go ('k') | grpc/cmd/rpc/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "os" 10 "os"
11 "os/exec" 11 "os/exec"
12 "os/signal" 12 "os/signal"
13 "sort" 13 "sort"
14 "strings" 14 "strings"
15 "sync" 15 "sync"
16 "time" 16 "time"
17 17
18 "golang.org/x/net/context" 18 "golang.org/x/net/context"
19 19
20 "github.com/golang/protobuf/proto" 20 "github.com/golang/protobuf/proto"
21 "github.com/luci/luci-go/client/flagpb" 21 "github.com/luci/luci-go/client/flagpb"
22 "github.com/luci/luci-go/common/cli" 22 "github.com/luci/luci-go/common/cli"
23 "github.com/luci/luci-go/common/clock" 23 "github.com/luci/luci-go/common/clock"
24 "github.com/luci/luci-go/common/errors" 24 "github.com/luci/luci-go/common/errors"
25 "github.com/luci/luci-go/common/lhttp"
25 "github.com/luci/luci-go/common/logging" 26 "github.com/luci/luci-go/common/logging"
26 "github.com/luci/luci-go/common/system/ctxcmd" 27 "github.com/luci/luci-go/common/system/ctxcmd"
27 dm "github.com/luci/luci-go/dm/api/service/v1" 28 dm "github.com/luci/luci-go/dm/api/service/v1"
28 "github.com/luci/luci-go/grpc/prpc" 29 "github.com/luci/luci-go/grpc/prpc"
29 "github.com/maruel/subcommands" 30 "github.com/maruel/subcommands"
30 ) 31 )
31 32
32 var cmdVisQuery = &subcommands.Command{ 33 var cmdVisQuery = &subcommands.Command{
33 UsageLine: `vis [options] [args for rpc command]`, 34 UsageLine: `vis [options] [args for rpc command]`,
34 ShortDesc: "Runs a DM WalkGraph query and visualizes the result to a .do t file.", 35 ShortDesc: "Runs a DM WalkGraph query and visualizes the result to a .do t file.",
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 189 }
189 ret.UpdateWith(newRet) 190 ret.UpdateWith(newRet)
190 if !newRet.HadMore { 191 if !newRet.HadMore {
191 return 192 return
192 } 193 }
193 query.Query = ret.ToQuery() 194 query.Query = ret.ToQuery()
194 } 195 }
195 return 196 return
196 } 197 }
197 198
198 func isLocalHost(host string) bool {
199 switch {
200 case host == "localhost", strings.HasPrefix(host, "localhost:"):
201 case host == "127.0.0.1", strings.HasPrefix(host, "127.0.0.1:"):
202 case host == "[::1]", strings.HasPrefix(host, "[::1]:"):
203 case strings.HasPrefix(host, ":"):
204
205 default:
206 return false
207 }
208 return true
209 }
210
211 func (r *visQueryRun) Run(a subcommands.Application, args []string) int { 199 func (r *visQueryRun) Run(a subcommands.Application, args []string) int {
212 r.cmd = cmdVisQuery 200 r.cmd = cmdVisQuery
213 201
214 c, cancel := context.WithCancel(cli.GetContext(a, r)) 202 c, cancel := context.WithCancel(cli.GetContext(a, r))
215 203
216 if r.path == "" && r.sequence { 204 if r.path == "" && r.sequence {
217 return r.argErr("path is required for sequence") 205 return r.argErr("path is required for sequence")
218 } 206 }
219 207
220 sigChan := make(chan os.Signal, 1) 208 sigChan := make(chan os.Signal, 1)
(...skipping 10 matching lines...) Expand all
231 return 1 219 return 1
232 } 220 }
233 if r.includeAll { 221 if r.includeAll {
234 query.Include = dm.MakeWalkGraphIncludeAll() 222 query.Include = dm.MakeWalkGraphIncludeAll()
235 } 223 }
236 224
237 client := &prpc.Client{ 225 client := &prpc.Client{
238 Host: r.host, 226 Host: r.host,
239 Options: prpc.DefaultOptions(), 227 Options: prpc.DefaultOptions(),
240 } 228 }
241 » client.Options.Insecure = isLocalHost(r.host) 229 » client.Options.Insecure = lhttp.IsLocalHost(r.host)
242 dc := dm.NewDepsPRPCClient(client) 230 dc := dm.NewDepsPRPCClient(client)
243 231
244 prev := "" 232 prev := ""
245 seq := 0 233 seq := 0
246 234
247 for c.Err() == nil { 235 for c.Err() == nil {
248 gdata, err := runQuery(c, dc, query) 236 gdata, err := runQuery(c, dc, query)
249 if err != nil { 237 if err != nil {
250 if errors.Contains(err, context.Canceled) { 238 if errors.Contains(err, context.Canceled) {
251 return 0 239 return 0
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return 0 279 return 0
292 } 280 }
293 } 281 }
294 } 282 }
295 } 283 }
296 284
297 clock.Sleep(c, time.Second/4) 285 clock.Sleep(c, time.Second/4)
298 } 286 }
299 return 0 287 return 0
300 } 288 }
OLDNEW
« no previous file with comments | « dm/appengine/distributor/jobsim/run.go ('k') | grpc/cmd/rpc/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698