mirror of
https://github.com/SpyHoodle/PrideFetch.git
synced 2024-11-09 21:25:42 +00:00
Refactor packages.py and add nixos (both profiles & nix-env)
This commit is contained in:
parent
3bd76dd35f
commit
97138dce31
32
packages.py
32
packages.py
@ -1,28 +1,20 @@
|
|||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
|
|
||||||
|
commands = [
|
||||||
|
"pacman -Qq",
|
||||||
|
"apt list --installed",
|
||||||
|
"yum list installed",
|
||||||
|
"dnf list installed",
|
||||||
|
"qlist -I",
|
||||||
|
"nix profile list",
|
||||||
|
"nix-env -q",
|
||||||
|
"rpm -qa",
|
||||||
|
]
|
||||||
|
|
||||||
def get_num_packages() -> (int, bool):
|
def get_num_packages() -> (int, bool):
|
||||||
|
for command in commands:
|
||||||
try:
|
try:
|
||||||
return len(check_output(["pacman", "-Qq"]).decode("utf-8").split("\n")) - 1
|
return len(check_output(command.split(" ")).decode("utf-8").split("\n")) - 1
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
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
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user