调整代码逻辑
This commit is contained in:
parent
71dfadcc87
commit
561232d079
|
@ -475,6 +475,96 @@ def error(parent, summary, message):
|
|||
d.destroy()
|
||||
return False
|
||||
|
||||
def get_broken_details(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 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
|
||||
|
||||
def check_free_space(cache):
|
||||
from .DistUpgradeCache import NotEnoughFreeSpaceError
|
||||
err_sum = _("Not enough free disk space")
|
||||
|
|
|
@ -12,7 +12,8 @@ from gettext import gettext as _
|
|||
import apt_pkg
|
||||
from SystemUpdater.Core.utils import (
|
||||
unLockedEnableShutdown,
|
||||
check_free_space
|
||||
check_free_space,
|
||||
get_broken_details
|
||||
)
|
||||
import time
|
||||
|
||||
|
@ -355,100 +356,10 @@ class InstallBackend():
|
|||
desc = str(e)
|
||||
logging.error(header + desc)
|
||||
|
||||
msg = self._get_broken_details(self.cache)
|
||||
msg = 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 = self.ACTION_DEFUALT_STATUS
|
||||
|
|
Loading…
Reference in New Issue