2022-04-20 17:03:28 +01:00
|
|
|
from subprocess import check_output
|
|
|
|
|
|
|
|
|
|
|
|
def get_num_packages() -> (int, bool):
|
|
|
|
try:
|
|
|
|
return len(check_output(["pacman", "-Qq"]).decode("utf-8").split("\n")) - 1
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
return len(check_output(["apt", "list", "--installed"]).decode("utf-8").split("\n")) - 1
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
return len(check_output(["yum", "list", "installed"]).decode("utf-8").split("\n")) - 1
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
return len(check_output(["dnf", "list", "installed"]).decode("utf-8").split("\n")) - 1
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
return len(check_output(["qlist", "-I"]).decode("utf-8").split("\n")) - 1
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
return len(check_output(["rpm", "-qa"]).decode("utf-8").split("\n")) - 1
|
|
|
|
except FileNotFoundError:
|
2022-04-20 17:48:59 +01:00
|
|
|
return False
|