Skip to content

Commit

Permalink
Fix issue with python-is-python3 not working and python being missing…
Browse files Browse the repository at this point in the history
… in later debian/ubuntu versions
  • Loading branch information
joshrendek committed Sep 17, 2023
1 parent 0f65d40 commit 0bceefb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions operating_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func rebootRequired() bool {
}
if agent.linux == "centos" {
out, _ := runner.Run("needs-restarting", "-r")
return strings.Contains(out,"Reboot is required")
return strings.Contains(out, "Reboot is required")
}
if agent.linux == "suse" {
out, _ := runner.Run("zypper", "ps", "-s")
Expand Down Expand Up @@ -84,7 +84,7 @@ func checkPreReqs() {
_, err := runner.Run("apt-get", "update")
out, err := runner.Run("apt-get", "install", "python", "-y")
if err != nil {
panic(err)
logging.LogMsg("error installing python, trying fallbacks: " + err.Error())
}
logging.LogMsg(out)
}
Expand All @@ -103,8 +103,10 @@ func checkPreReqs() {
// Specifically for Ubuntu 21+/Debian11+
out, err := runner.Run("python", "trex.py")
if err != nil {
logging.LogMsg("error running python-apt: " + err.Error())
if strings.Contains(out, "ImportError: No module named apt") {
logging.LogMsg("error running python-apt(err): " + err.Error())
logging.LogMsg("error running python-apt(out): " + out)
if strings.Contains(out, "ImportError: No module named apt") ||
strings.Contains(err.Error(), "executable file not found in") {
logging.LogMsg("installing python-is-python3")
_, err := runner.Run("apt-get", "install", "python-is-python3", "-y")
if err != nil {
Expand Down

0 comments on commit 0bceefb

Please sign in to comment.