添加功能 当依赖解决器出问题时,报出什么原因导致的错误
This commit is contained in:
parent
195910dbc1
commit
231eb066ef
|
@ -311,14 +311,103 @@ class InstallBackend():
|
|||
except Exception as e:
|
||||
_success = False
|
||||
header = _("Could not calculate the upgrade")
|
||||
desc = _("An unresolvable problem occurred while "
|
||||
"calculating the upgrade.\n\n"
|
||||
"Please report this bug against the 'kylin-system-updater' "
|
||||
"package and include the following error "
|
||||
"message:\n") + str(e)
|
||||
desc = str(e)
|
||||
logging.error(header + desc)
|
||||
|
||||
msg = self._get_broken_details(self.cache)
|
||||
logging.error(msg)
|
||||
return _success,[],[],header,desc
|
||||
|
||||
def _get_broken_details(self,cache,now=False):
|
||||
"""Return a message which provides debugging information about
|
||||
broken packages.
|
||||
|
||||
This method is basically a Python implementation of apt-get.cc's
|
||||
ShowBroken.
|
||||
|
||||
Keyword arguments:
|
||||
trans -- the corresponding transaction
|
||||
now -- if we check currently broken dependecies or the installation
|
||||
candidate
|
||||
"""
|
||||
msg = _("The following packages have unmet dependencies:")
|
||||
msg += "\n\n"
|
||||
for pkg in cache:
|
||||
if not ((now and pkg.is_now_broken) or
|
||||
(not now and pkg.is_inst_broken)):
|
||||
continue
|
||||
msg += "%s: " % pkg.name
|
||||
if now:
|
||||
version = pkg.installed
|
||||
else:
|
||||
version = pkg.candidate
|
||||
indent = " " * (len(pkg.name) + 2)
|
||||
dep_msg = ""
|
||||
for dep in version.dependencies:
|
||||
or_msg = ""
|
||||
for base_dep in dep.or_dependencies:
|
||||
if or_msg:
|
||||
or_msg += "or\n"
|
||||
or_msg += indent
|
||||
# Check if it's an important dependency
|
||||
# See apt-pkg/depcache.cc IsImportantDep
|
||||
# See apt-pkg/pkgcache.cc IsCritical()
|
||||
if not (base_dep.rawtype in ["Depends", "PreDepends",
|
||||
"Obsoletes", "DpkgBreaks",
|
||||
"Conflicts"] or
|
||||
(apt_pkg.config.find_b("APT::Install-Recommends",
|
||||
False) and
|
||||
base_dep.rawtype == "Recommends") or
|
||||
(apt_pkg.config.find_b("APT::Install-Suggests",
|
||||
False) and
|
||||
base_dep.rawtype == "Suggests")):
|
||||
continue
|
||||
# Get the version of the target package
|
||||
try:
|
||||
pkg_dep = cache[base_dep.name]
|
||||
except KeyError:
|
||||
dep_version = None
|
||||
else:
|
||||
if now:
|
||||
dep_version = pkg_dep.installed
|
||||
else:
|
||||
dep_version = pkg_dep.candidate
|
||||
# We only want to display dependencies which cannot
|
||||
# be satisfied
|
||||
if dep_version and not apt_pkg.check_dep(base_dep.version,
|
||||
base_dep.relation,
|
||||
version.version):
|
||||
break
|
||||
or_msg = "%s: %s " % (base_dep.rawtype, base_dep.name)
|
||||
if base_dep.version:
|
||||
or_msg += "(%s %s) " % (base_dep.relation,
|
||||
base_dep.version)
|
||||
if self._cache.is_virtual_package(base_dep.name):
|
||||
or_msg += _("but it is a virtual package")
|
||||
elif not dep_version:
|
||||
if now:
|
||||
or_msg += _("but it is not installed")
|
||||
else:
|
||||
or_msg += _("but it is not going to "
|
||||
"be installed")
|
||||
elif now:
|
||||
# TRANSLATORS: %s is a version number
|
||||
or_msg += (("but %s is installed") %
|
||||
dep_version.version)
|
||||
else:
|
||||
# TRANSLATORS: %s is a version number
|
||||
or_msg += (("but %s is to be installed") %
|
||||
dep_version.version)
|
||||
else:
|
||||
# Only append an or-group if at least one of the
|
||||
# dependencies cannot be satisfied
|
||||
if dep_msg:
|
||||
dep_msg += indent
|
||||
dep_msg += or_msg
|
||||
dep_msg += "\n"
|
||||
msg += dep_msg
|
||||
return msg
|
||||
|
||||
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
|
||||
def _action_done(self, action, authorized, success, error_string,error_desc):
|
||||
self.window_main.is_working = False
|
||||
|
|
Loading…
Reference in New Issue