github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/pkg/inspector/check/python.go (about) 1 package check 2 3 import ( 4 "errors" 5 "os/exec" 6 "strings" 7 ) 8 9 // Python2Check returns true if python 2 is installed on the node 10 // and the version prefix-matches one of the supported versions 11 type Python2Check struct { 12 SupportedVersions []string 13 } 14 15 func (c Python2Check) Check() (bool, error) { 16 cmd := exec.Command("python", "--version") 17 out, err := cmd.CombinedOutput() 18 if err != nil { 19 return false, errors.New("Python 2 doesn't seem to be installed") 20 } 21 for _, version := range c.SupportedVersions { 22 if strings.HasPrefix(string(out), version) { 23 return true, nil 24 } 25 } 26 return false, nil 27 }