| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 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 python | 5 package python |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "os/exec" | 8 "os/exec" |
| 9 | 9 |
| 10 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 if e, ok := err.(*exec.Error); ok && e.Err == exec.ErrNo
tFound { | 38 if e, ok := err.(*exec.Error); ok && e.Err == exec.ErrNo
tFound { |
| 39 // Not found is okay. | 39 // Not found is okay. |
| 40 continue | 40 continue |
| 41 } | 41 } |
| 42 return nil, errors.Annotate(err).Reason("failed to searc
h PATH for: %(interp)q"). | 42 return nil, errors.Annotate(err).Reason("failed to searc
h PATH for: %(interp)q"). |
| 43 D("interp", s). | 43 D("interp", s). |
| 44 Err() | 44 Err() |
| 45 } | 45 } |
| 46 | 46 |
| 47 i := Interpreter{Python: p} | 47 i := Interpreter{Python: p} |
| 48 if err := i.Normalize(); err != nil { |
| 49 return nil, err |
| 50 } |
| 51 |
| 48 iv, err := i.GetVersion(c) | 52 iv, err := i.GetVersion(c) |
| 49 if err != nil { | 53 if err != nil { |
| 50 return nil, errors.Annotate(err).Reason("failed to get v
ersion for: %(interp)q"). | 54 return nil, errors.Annotate(err).Reason("failed to get v
ersion for: %(interp)q"). |
| 51 » » » » D("interp", p). | 55 » » » » D("interp", i.Python). |
| 52 Err() | 56 Err() |
| 53 } | 57 } |
| 54 if vers.IsSatisfiedBy(iv) { | 58 if vers.IsSatisfiedBy(iv) { |
| 55 return &i, nil | 59 return &i, nil |
| 56 } | 60 } |
| 57 } | 61 } |
| 58 | 62 |
| 59 return nil, errors.New("no Python found") | 63 return nil, errors.New("no Python found") |
| 60 } | 64 } |
| OLD | NEW |