[packages] Convert command-failures into readable error messages
If the pakcage manager fails in some way, convert to a readable error message instead of leaking the exception to the caller (which produces a traceback, which is harder to read and less informative)
This commit is contained in:
parent
bb1df38caa
commit
aa4569b55b
@ -579,11 +579,27 @@ def run():
|
|||||||
|
|
||||||
update_db = libcalamares.job.configuration.get("update_db", False)
|
update_db = libcalamares.job.configuration.get("update_db", False)
|
||||||
if update_db and libcalamares.globalstorage.value("hasInternet"):
|
if update_db and libcalamares.globalstorage.value("hasInternet"):
|
||||||
|
try:
|
||||||
pkgman.update_db()
|
pkgman.update_db()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
libcalamares.utils.warning(str(e))
|
||||||
|
libcalamares.utils.debug("stdout:" + str(e.stdout))
|
||||||
|
libcalamares.utils.debug("stderr:" + str(e.stderr))
|
||||||
|
return (_("Package Manager error"),
|
||||||
|
_("The package manager could not prepare updates. The command <pre>{!s}</pre> returned error code {!s}.")
|
||||||
|
.format(e.cmd, e.returncode))
|
||||||
|
|
||||||
update_system = libcalamares.job.configuration.get("update_system", False)
|
update_system = libcalamares.job.configuration.get("update_system", False)
|
||||||
if update_system and libcalamares.globalstorage.value("hasInternet"):
|
if update_system and libcalamares.globalstorage.value("hasInternet"):
|
||||||
|
try:
|
||||||
pkgman.update_system()
|
pkgman.update_system()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
libcalamares.utils.warning(str(e))
|
||||||
|
libcalamares.utils.debug("stdout:" + str(e.stdout))
|
||||||
|
libcalamares.utils.debug("stderr:" + str(e.stderr))
|
||||||
|
return (_("Package Manager error"),
|
||||||
|
_("The package manager could not update the system. The command <pre>{!s}</pre> returned error code {!s}.")
|
||||||
|
.format(e.cmd, e.returncode))
|
||||||
|
|
||||||
operations = libcalamares.job.configuration.get("operations", [])
|
operations = libcalamares.job.configuration.get("operations", [])
|
||||||
if libcalamares.globalstorage.contains("packageOperations"):
|
if libcalamares.globalstorage.contains("packageOperations"):
|
||||||
@ -603,11 +619,18 @@ def run():
|
|||||||
for entry in operations:
|
for entry in operations:
|
||||||
group_packages = 0
|
group_packages = 0
|
||||||
libcalamares.utils.debug(pretty_name())
|
libcalamares.utils.debug(pretty_name())
|
||||||
|
try:
|
||||||
run_operations(pkgman, entry)
|
run_operations(pkgman, entry)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
libcalamares.utils.warning(str(e))
|
||||||
|
libcalamares.utils.debug("stdout:" + str(e.stdout))
|
||||||
|
libcalamares.utils.debug("stderr:" + str(e.stderr))
|
||||||
|
return (_("Package Manager error"),
|
||||||
|
_("The package manager could make changes to the installed system. The command <pre>{!s}</pre> returned error code {!s}.")
|
||||||
|
.format(e.cmd, e.returncode))
|
||||||
|
|
||||||
mode_packages = None
|
mode_packages = None
|
||||||
|
|
||||||
libcalamares.job.setprogress(1.0)
|
libcalamares.job.setprogress(1.0)
|
||||||
libcalamares.utils.debug(pretty_name())
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user