mirror of
https://github.com/SpyHoodle/PrideFetch.git
synced 2024-11-09 21:25:42 +00:00
28 lines
930 B
Python
28 lines
930 B
Python
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:
|
|
return False |