PrideFetch/packages.py

29 lines
931 B
Python
Raw Normal View History

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