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) currently_installed)
l.print_list_summary("Installing pacman packages:", to_install_pacman) 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: if not self.only_print:
self.pacman.install(to_install_pacman) self.pacman.install(to_install_pacman)
+29 -4
View File
@@ -644,6 +644,9 @@ class Pacman:
""" """
Installs the given packages. Installs the given packages.
""" """
if not packages:
return
try: try:
subprocess.run(conf.commands.install_pkgs(packages), check=True) subprocess.run(conf.commands.install_pkgs(packages), check=True)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
@@ -654,6 +657,9 @@ class Pacman:
""" """
Installs the given dependencies. Installs the given dependencies.
""" """
if not deps:
return
try: try:
subprocess.run(conf.commands.install_deps(deps), check=True) subprocess.run(conf.commands.install_deps(deps), check=True)
except subprocess.CalledProcessError as error: 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 Installs the given files first as dependencies. Then the packages listed in as_explicit are
installed explicitly. installed explicitly.
""" """
if not files:
return
try: try:
subprocess.run(conf.commands.install_files(files), check=True) subprocess.run(conf.commands.install_files(files), check=True)
subprocess.run(
conf.commands.set_as_explicitly_installed(as_explicit), if as_explicit:
check=True, subprocess.run(
capture_output=conf.suppress_command_output) conf.commands.set_as_explicitly_installed(as_explicit),
check=True,
capture_output=conf.suppress_command_output)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
if conf.suppress_command_output: if conf.suppress_command_output:
print_error("Output:") print_error("Output:")
@@ -693,6 +704,8 @@ class Pacman:
""" """
Removes the given packages. Removes the given packages.
""" """
if not packages:
return
try: try:
subprocess.run(conf.commands.remove(packages), check=True) subprocess.run(conf.commands.remove(packages), check=True)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
@@ -712,6 +725,9 @@ class Systemd:
""" """
Enables the given units. Enables the given units.
""" """
if not units:
return
try: try:
subprocess.run(conf.commands.enable_units(units), check=True) subprocess.run(conf.commands.enable_units(units), check=True)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
@@ -723,6 +739,9 @@ class Systemd:
""" """
Disables the given units. Disables the given units.
""" """
if not units:
return
try: try:
subprocess.run(conf.commands.disable_units(units), check=True) subprocess.run(conf.commands.disable_units(units), check=True)
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
@@ -738,6 +757,9 @@ class Systemd:
""" """
Enables the given units for the given user. Enables the given units for the given user.
""" """
if not units:
return
try: try:
uid = pwd.getpwnam(user).pw_uid uid = pwd.getpwnam(user).pw_uid
gid = pwd.getpwnam(user).pw_gid gid = pwd.getpwnam(user).pw_gid
@@ -759,6 +781,9 @@ class Systemd:
""" """
Disables the given units for the given user. Disables the given units for the given user.
""" """
if not units:
return
try: try:
uid = pwd.getpwnam(user).pw_uid uid = pwd.getpwnam(user).pw_uid
gid = pwd.getpwnam(user).pw_gid gid = pwd.getpwnam(user).pw_gid