Add checks for empty lists

This commit is contained in:
Kivi Kaitaniemi
2024-05-16 21:24:25 +03:00
parent 948914c270
commit 5fb0eeb728
2 changed files with 34 additions and 5 deletions
+5 -1
View File
@@ -227,7 +227,11 @@ class Core:
currently_installed)
l.print_list_summary("Installing pacman packages:", to_install_pacman)
l.print_list_summary("Installing foreign packages:", to_install_fpm)
# fpm prints a summary so no need to print it twice
if self.only_print:
l.print_list_summary("Installing foreign packages:",
to_install_fpm)
if not self.only_print:
self.pacman.install(to_install_pacman)
+29 -4
View File
@@ -644,6 +644,9 @@ class Pacman:
"""
Installs the given packages.
"""
if not packages:
return
try:
subprocess.run(conf.commands.install_pkgs(packages), check=True)
except subprocess.CalledProcessError as error:
@@ -654,6 +657,9 @@ class Pacman:
"""
Installs the given dependencies.
"""
if not deps:
return
try:
subprocess.run(conf.commands.install_deps(deps), check=True)
except subprocess.CalledProcessError as error:
@@ -666,12 +672,17 @@ class Pacman:
Installs the given files first as dependencies. Then the packages listed in as_explicit are
installed explicitly.
"""
if not files:
return
try:
subprocess.run(conf.commands.install_files(files), check=True)
subprocess.run(
conf.commands.set_as_explicitly_installed(as_explicit),
check=True,
capture_output=conf.suppress_command_output)
if as_explicit:
subprocess.run(
conf.commands.set_as_explicitly_installed(as_explicit),
check=True,
capture_output=conf.suppress_command_output)
except subprocess.CalledProcessError as error:
if conf.suppress_command_output:
print_error("Output:")
@@ -693,6 +704,8 @@ class Pacman:
"""
Removes the given packages.
"""
if not packages:
return
try:
subprocess.run(conf.commands.remove(packages), check=True)
except subprocess.CalledProcessError as error:
@@ -712,6 +725,9 @@ class Systemd:
"""
Enables the given units.
"""
if not units:
return
try:
subprocess.run(conf.commands.enable_units(units), check=True)
except subprocess.CalledProcessError as error:
@@ -723,6 +739,9 @@ class Systemd:
"""
Disables the given units.
"""
if not units:
return
try:
subprocess.run(conf.commands.disable_units(units), check=True)
except subprocess.CalledProcessError as error:
@@ -738,6 +757,9 @@ class Systemd:
"""
Enables the given units for the given user.
"""
if not units:
return
try:
uid = pwd.getpwnam(user).pw_uid
gid = pwd.getpwnam(user).pw_gid
@@ -759,6 +781,9 @@ class Systemd:
"""
Disables the given units for the given user.
"""
if not units:
return
try:
uid = pwd.getpwnam(user).pw_uid
gid = pwd.getpwnam(user).pw_gid