mirror of
https://github.com/SpyHoodle/PrideFetch.git
synced 2024-11-22 19:05:41 +00:00
Refactor packages.py and add nixos (both profiles & nix-env)
This commit is contained in:
parent
3bd76dd35f
commit
97138dce31
40
packages.py
40
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):
|
||||||
try:
|
for command in commands:
|
||||||
return len(check_output(["pacman", "-Qq"]).decode("utf-8").split("\n")) - 1
|
try:
|
||||||
except FileNotFoundError:
|
return len(check_output(command.split(" ")).decode("utf-8").split("\n")) - 1
|
||||||
pass
|
except FileNotFoundError:
|
||||||
try:
|
pass
|
||||||
return len(check_output(["apt", "list", "--installed"]).decode("utf-8").split("\n")) - 1
|
return False
|
||||||
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user