From ee7b1ef76f58e8dd3a744af98007c4ab8b5ab6d2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 19 Aug 2009 16:39:57 +0200 Subject: * apt/cache.py, python/cache.cc: - add optional pulseIntevall option to "update()" * po/python-apt.pot: - refreshed --- apt/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index c1e2428c..bb396d59 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -270,7 +270,7 @@ class Cache(object): providers.append(pkg) return providers - def update(self, fetchProgress=None): + def update(self, fetchProgress=None, pulseInterval=0): " run the equivalent of apt-get update " lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" lock = apt_pkg.GetLock(lockfile) @@ -280,7 +280,7 @@ class Cache(object): try: if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() - return self._cache.Update(fetchProgress, self._list) + return self._cache.Update(fetchProgress, self._list, pulseInterval) finally: os.close(lock) -- cgit v1.2.3 From e2d814ffc20e231a3b8201f7d66145939c99174c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 21 Aug 2009 15:18:33 +0200 Subject: * apt/cache.py: Introduce ProblemResolver class (Closes: #542705) --- apt/__init__.py | 2 +- apt/cache.py | 35 ++++++++++++++++++++++++++++++++++- debian/changelog | 4 +++- doc/source/apt/cache.rst | 5 +++++ doc/source/apt/index.rst | 3 +++ 5 files changed, 46 insertions(+), 3 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/__init__.py b/apt/__init__.py index ae2abbf2..4b3e6bf2 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -23,7 +23,7 @@ import os # import some fancy classes from apt.package import Package -from apt.cache import Cache +from apt.cache import Cache, ProblemResolver from apt.progress import ( OpProgress, FetchProgress, InstallProgress, CdromProgress) from apt.cdrom import Cdrom diff --git a/apt/cache.py b/apt/cache.py index c1e2428c..33d55368 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -91,7 +91,6 @@ class Cache(object): for f in files: if not os.path.exists(rootdir+f): open(rootdir+f,"w") - def _runCallbacks(self, name): """ internal helper to run a callback """ @@ -363,6 +362,40 @@ class Cache(object): return self._depcache.keep_count +class ProblemResolver(object): + """Resolve problems due to dependencies and conflicts. + + The first argument 'cache' is an instance of apt.Cache. + """ + + def __init__(self, cache): + self._resolver = apt_pkg.GetPkgProblemResolver(cache._depcache) + + def clear(self, package): + """Reset the package to the default state.""" + self._resolver.Clear(package._pkg) + + def install_protect(self): + """mark protected packages for install or removal.""" + self._resolver.InstallProtect() + + def protect(self, package): + """Protect a package so it won't be removed.""" + self._resolver.Protect(package._pkg) + + def remove(self, package): + """Mark a package for removal.""" + self._resolver.Remove(package._pkg) + + def resolve(self): + """Resolve dependencies, try to remove packages where needed.""" + self._resolver.Resolve() + + def resolve_by_keep(self): + """Resolve dependencies, do not try to remove packages.""" + self._resolver.ResolveByKeep() + + # ----------------------------- experimental interface diff --git a/debian/changelog b/debian/changelog index d91b90a5..bf5a6036 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.12.2) UNRELEASED; urgency=low +python-apt (0.7.13.0) UNRELEASED; urgency=low [ Michael Vogt ] * apt/package.py: @@ -10,6 +10,8 @@ python-apt (0.7.12.2) UNRELEASED; urgency=low of dependencies and returns a list of Dependency objects. - Do not mark the package as manually installed on upgrade (Closes: #542699) - Add Package.is_now_broken and Package.is_inst_broken. + * apt/cache.py: + - Introduce ProblemResolver class (Closes: #542705) -- Julian Andres Klode Fri, 21 Aug 2009 14:57:08 +0200 diff --git a/doc/source/apt/cache.rst b/doc/source/apt/cache.rst index d96cba97..beae74a2 100644 --- a/doc/source/apt/cache.rst +++ b/doc/source/apt/cache.rst @@ -70,6 +70,11 @@ packages whose state has been changed, eg. packages marked for installation:: >>> print len(changed) == len(cache.GetChanges()) # Both need to have same length True +The ProblemResolver class +-------------------------- + +.. autoclass:: ProblemResolver + :members: Exceptions ---------- diff --git a/doc/source/apt/index.rst b/doc/source/apt/index.rst index 5047a0fd..bf39354f 100644 --- a/doc/source/apt/index.rst +++ b/doc/source/apt/index.rst @@ -56,3 +56,6 @@ in the package. Please see :class:`apt.package.Package` for documentation. +.. class:: ProblemResolver + + Please see :class:`apt.cache.ProblemResolver` for documentation. -- cgit v1.2.3 From a65009779237610d6be290222aeb69af8b19ad34 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Fri, 21 Aug 2009 15:26:31 +0200 Subject: apt/cache.py: Fix the (inst|keep|broken|del)_count attributes (Closes: #542773). --- apt/cache.py | 8 ++++---- debian/changelog | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index 33d55368..bc1d1160 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -344,22 +344,22 @@ class Cache(object): @property def broken_count(self): """Return the number of packages with broken dependencies.""" - return self._depcache.broken_count + return self._depcache.BrokenCount @property def delete_count(self): """Return the number of packages marked for deletion.""" - return self._depcache.del_count + return self._depcache.DelCount @property def install_count(self): """Return the number of packages marked for installation.""" - return self._depcache.inst_count + return self._depcache.InstCount @property def keep_count(self): """Return the number of packages marked as keep.""" - return self._depcache.keep_count + return self._depcache.KeepCount class ProblemResolver(object): diff --git a/debian/changelog b/debian/changelog index bf5a6036..575db1b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ python-apt (0.7.13.0) UNRELEASED; urgency=low * apt/package.py: - add "recommends" property + [ Sebastian Heinlein ] + * apt/cache.py: + - Fix the (inst|keep|broken|del)_count attributes (Closes: #542773). + [ Julian Andres Klode ] * apt/package.py: - Introduce Version.get_dependencies() which takes one or more types -- cgit v1.2.3