[packages] Make callback logic more sensible
This commit is contained in:
parent
e1e29780f2
commit
c80b4ff4c2
@ -406,13 +406,17 @@ class PMPacman(PackageManager):
|
|||||||
# These are globals
|
# These are globals
|
||||||
self.progress_fraction = (completed_packages * 1.0 / total_packages)
|
self.progress_fraction = (completed_packages * 1.0 / total_packages)
|
||||||
|
|
||||||
def run_pacman(self, command, callback=None):
|
def run_pacman(self, command, callback=False):
|
||||||
# Call pacman in a loop until it is successful or the number of retries is exceeded
|
# Call pacman in a loop until it is successful or the number of retries is exceeded
|
||||||
pacman_count = 0
|
pacman_count = 0
|
||||||
while pacman_count <= self.pacman_num_retries:
|
while pacman_count <= self.pacman_num_retries:
|
||||||
pacman_count += 1
|
pacman_count += 1
|
||||||
try:
|
try:
|
||||||
libcalamares.utils.target_env_process_output(command, callback)
|
if callback is True:
|
||||||
|
libcalamares.utils.target_env_process_output(command, self.line_cb)
|
||||||
|
else:
|
||||||
|
libcalamares.utils.target_env_process_output(command)
|
||||||
|
|
||||||
return
|
return
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
if pacman_count <= self.pacman_num_retries:
|
if pacman_count <= self.pacman_num_retries:
|
||||||
@ -438,13 +442,13 @@ class PMPacman(PackageManager):
|
|||||||
|
|
||||||
command += pkgs
|
command += pkgs
|
||||||
|
|
||||||
self.run_pacman(command, self.line_cb)
|
self.run_pacman(command, True)
|
||||||
|
|
||||||
self.reset_progress()
|
self.reset_progress()
|
||||||
|
|
||||||
def remove(self, pkgs):
|
def remove(self, pkgs):
|
||||||
self.reset_progress()
|
self.reset_progress()
|
||||||
self.run_pacman(["pacman", "-Rs", "--noconfirm"] + pkgs, self.line_cb)
|
self.run_pacman(["pacman", "-Rs", "--noconfirm"] + pkgs, True)
|
||||||
|
|
||||||
def update_db(self):
|
def update_db(self):
|
||||||
self.run_pacman(["pacman", "-Sy"])
|
self.run_pacman(["pacman", "-Sy"])
|
||||||
@ -454,7 +458,7 @@ class PMPacman(PackageManager):
|
|||||||
if self.pacman_disable_timeout is True:
|
if self.pacman_disable_timeout is True:
|
||||||
command.append("--disable-download-timeout")
|
command.append("--disable-download-timeout")
|
||||||
|
|
||||||
self.run_pacman(command, self.line_cb)
|
self.run_pacman(command, True)
|
||||||
|
|
||||||
|
|
||||||
class PMPamac(PackageManager):
|
class PMPamac(PackageManager):
|
||||||
|
Loading…
Reference in New Issue
Block a user