From 4fcfe8b00e52a21c2144877fb631a70d6c75fd19 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 22 Aug 2009 22:56:18 +0200 Subject: apt/cache.py: Convert argument to str in __getitem__() (Closes: #542965). --- apt/cache.py | 1 + debian/changelog | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/apt/cache.py b/apt/cache.py index 756f9ba9..446cfae7 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -135,6 +135,7 @@ class Cache(object): return self._weakref[key] except KeyError: if key in self._set: + key = str(key) pkg = self._weakref[key] = Package(self, self._cache[key]) return pkg else: diff --git a/debian/changelog b/debian/changelog index b75d07b7..2da5bc58 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.13.2) unstable; urgency=low + + * apt/cache.py: + - Convert argument to str in __getitem__() (Closes: #542965). + + -- Julian Andres Klode Sat, 22 Aug 2009 22:47:30 +0200 + python-apt (0.7.13.1) unstable; urgency=low * apt/package.py: -- cgit v1.2.3 From 8c708ec819333e0360b815bbbb504460e9f15d9a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 24 Aug 2009 13:40:43 +0200 Subject: * apt/cache.py: - add actiongroup() method (backport from 0.7.92) --- apt/cache.py | 9 +++++++++ debian/changelog | 2 ++ 2 files changed, 11 insertions(+) diff --git a/apt/cache.py b/apt/cache.py index bb396d59..d46cd078 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -335,6 +335,15 @@ class Cache(object): a signal then """ self._runCallbacks("cache_pre_change") + def actiongroup(self): + """Return an ActionGroup() object for the current cache. + + Action groups can be used to speedup actions. The action group is + active as soon as it is created, and disabled when the object is + deleted or when release() is called. + """ + return apt_pkg.GetPkgActionGroup(self._depcache) + def connect(self, name, callback): """ connect to a signal, currently only used for cache_{post,pre}_{changed,open} """ diff --git a/debian/changelog b/debian/changelog index 3f22d113..22d14fa7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ python-apt (0.7.12.2) UNRELEASED; urgency=low - add optional pulseIntevall option to "update()" * po/python-apt.pot: - refreshed + * apt/cache.py: + - add actiongroup() method (backport from 0.7.92) [ Julian Andres Klode ] * apt/package.py: -- cgit v1.2.3 From b564655353399acb70431b31c63f3df08c5d42ab Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 24 Aug 2009 15:46:29 +0200 Subject: * python/depcache.cc: - Make ActionGroups context managers so apt.Cache.actiongroup() has the same behavior as in 0.7.92 --- debian/changelog | 10 ++++++++-- python/depcache.cc | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index eddd9194..00900dad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,16 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low + [ Michael Vogt ] * apt/cache.py: - add actiongroup() method (backport from 0.7.92) - -- Michael Vogt Mon, 24 Aug 2009 13:41:38 +0200 - + [ Julian Andres Klode ] + * python/depcache.cc: + - Make ActionGroups context managers so apt.Cache.actiongroup() has + the same behavior as in 0.7.92 + + -- Julian Andres Klode Mon, 24 Aug 2009 15:43:00 +0200 + python-apt (0.7.13.2) unstable; urgency=low * apt/cache.py: diff --git a/python/depcache.cc b/python/depcache.cc index 0e83c956..7edb7b59 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -794,9 +794,24 @@ static PyObject *PkgActionGroupRelease(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } +static PyObject *PkgActionGroupEnter(PyObject *Self,PyObject *Args) { + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + Py_INCREF(Self); + return Self; +} +static PyObject *PkgActionGroupExit(PyObject *Self,PyObject *Args) { + pkgDepCache::ActionGroup *ag = GetCpp(Self); + ag->release(); + Py_RETURN_FALSE; +} + + static PyMethodDef PkgActionGroupMethods[] = { {"release", PkgActionGroupRelease, METH_VARARGS, "release()"}, + {"__enter__", PkgActionGroupEnter, METH_VARARGS, "__enter__() -> self"}, + {"__exit__", PkgActionGroupExit, METH_VARARGS, "__exit__()"}, {} }; -- cgit v1.2.3 From d914d4c1e241f8e511361b9ce98993ca8e1b98af Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Tue, 25 Aug 2009 08:41:26 +0200 Subject: apt/package.py: Export if a package is an essential one (Closes: #543428) --- apt/package.py | 5 +++++ debian/changelog | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/apt/package.py b/apt/package.py index d639f31f..27e0dc90 100644 --- a/apt/package.py +++ b/apt/package.py @@ -652,6 +652,11 @@ class Package(object): This returns the same value as ID, which is unique.""" return self._pkg.ID + @property + def essential(self): + """Return True if the package is an essential part of the system.""" + return self._pkg.Essential + @DeprecatedProperty def installedVersion(self): """Return the installed version as string. diff --git a/debian/changelog b/debian/changelog index 00900dad..bfba50e0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low * apt/cache.py: - add actiongroup() method (backport from 0.7.92) + [ Sebastian Heinlein ] + * apt/package.py: + - Export if a package is an essential one (Closes: #543428) + [ Julian Andres Klode ] * python/depcache.cc: - Make ActionGroups context managers so apt.Cache.actiongroup() has -- cgit v1.2.3 From 4be008cb4dcaa8d6a97b1e3393bc68f9cc48655e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 28 Aug 2009 14:39:22 +0200 Subject: apt/package.py: Use the source version instead of the binary version in fetch_source(). --- apt/package.py | 7 ++++--- debian/changelog | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apt/package.py b/apt/package.py index 27e0dc90..6a85d2b5 100644 --- a/apt/package.py +++ b/apt/package.py @@ -478,10 +478,11 @@ class Version(object): acq = apt_pkg.GetAcquire(progress or apt.progress.TextFetchProgress()) dsc = None - src.Lookup(self.package.name) + record = self._records + src.Lookup(record.SourcePkg) try: - while self.version != src.Version: - src.Lookup(self.package.name) + while record.SourceVer != src.Version: + src.Lookup(record.SourcePkg) except AttributeError: raise ValueError("No source for %r" % self) for md5, size, path, type in src.Files: diff --git a/debian/changelog b/debian/changelog index bfba50e0..6babe14c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,8 +12,10 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low * python/depcache.cc: - Make ActionGroups context managers so apt.Cache.actiongroup() has the same behavior as in 0.7.92 + * apt/package.py: + - Use the source version instead of the binary version in fetch_source(). - -- Julian Andres Klode Mon, 24 Aug 2009 15:43:00 +0200 + -- Julian Andres Klode Fri, 28 Aug 2009 14:38:06 +0200 python-apt (0.7.13.2) unstable; urgency=low -- cgit v1.2.3 From 0aa3f4f3ce25a499a332c23f9493e629f30013dc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Sep 2009 20:45:52 +0200 Subject: re-work the logic in commit() to fail if installArchives() returns a unexpected result --- apt/cache.py | 6 +++++- debian/changelog | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apt/cache.py b/apt/cache.py index 828b167b..bb944041 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -314,8 +314,12 @@ class Cache(object): res = self.installArchives(pm, installProgress) if res == pm.ResultCompleted: break - if res == pm.ResultFailed: + elif res == pm.ResultFailed: raise SystemError("installArchives() failed") + elif res == pm.ResultIncomplete: + pass + else: + raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res) # reload the fetcher for media swaping fetcher.Shutdown() return (res == pm.ResultCompleted) diff --git a/debian/changelog b/debian/changelog index bfba50e0..ada400bb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low [ Michael Vogt ] * apt/cache.py: - add actiongroup() method (backport from 0.7.92) + - re-work the logic in commit() to fail if installArchives() returns + a unexpected result [ Sebastian Heinlein ] * apt/package.py: -- cgit v1.2.3 From 0d4a8172a7bceac5bdca37cc199d9bfba889cc4f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 3 Sep 2009 08:46:33 +0200 Subject: apt/progress/__init__.py: doc update --- apt/progress/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 337bd161..3a6b3f91 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -284,7 +284,11 @@ class InstallProgress(DumbInstallProgress): return os.fork() def waitChild(self): - """Wait for child progress to exit.""" + """Wait for child progress to exit. + + The return values is the full status returned from os.waitpid() + (not only the return code). + """ while True: try: select.select([self.statusfd], [], [], self.selectTimeout) -- cgit v1.2.3 From 2ca7c7acd3f47dc7da07fd8ad77df8c0c6c84735 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 3 Sep 2009 15:01:01 +0200 Subject: * apt/progress/__init__.py: - catch exceptions in pm.DoInstall() --- apt/progress/__init__.py | 11 +++++++++-- debian/changelog | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 3a6b3f91..97090643 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -311,8 +311,15 @@ class InstallProgress(DumbInstallProgress): """Start installing.""" pid = self.fork() if pid == 0: - # child - res = pm.DoInstall(self.writefd) + # pm.DoInstall might raise a exception, + # when this happens, we need to catch + # it, otherwise os._exit() is not run + # and the execution continues in the + # parent code leading to very confusing bugs + try: + res = pm.DoInstall(self.writefd) + except Exception, e: + os._exit(pm.ResultFailed) os._exit(res) self.child_pid = pid res = self.waitChild() diff --git a/debian/changelog b/debian/changelog index ada400bb..3f23a368 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low - add actiongroup() method (backport from 0.7.92) - re-work the logic in commit() to fail if installArchives() returns a unexpected result + * apt/progress/__init__.py: + - catch exceptions in pm.DoInstall() [ Sebastian Heinlein ] * apt/package.py: -- cgit v1.2.3 From 7acb16fc4baa43cf2cbbc4de948973bdc099d878 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 3 Sep 2009 15:21:23 +0200 Subject: apt/progress/__init__.py: doc string update for run() --- apt/progress/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 97090643..ca60810f 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -308,7 +308,11 @@ class InstallProgress(DumbInstallProgress): return res def run(self, pm): - """Start installing.""" + """Start installing. + + Returns the PackageManager status: + (pm.ResultCompleted, pm.ResultFailed, pm.ResultIncomplete) + """ pid = self.fork() if pid == 0: # pm.DoInstall might raise a exception, -- cgit v1.2.3 From 7fe83be76c6aac0778225a0106b46293d34543bf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 10 Sep 2009 19:13:59 +0200 Subject: apt/progress/__init__.py: Correctly ignore ECHILD by checking before EINTR (Closes: #546007) As the check for != EINTR will re-raise the error, we have to check ECHILD before it. --- apt/progress/__init__.py | 4 ++-- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 337bd161..9f348ffd 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -297,10 +297,10 @@ class InstallProgress(DumbInstallProgress): if pid == self.child_pid: break except OSError, (errno_, errstr): - if errno_ != errno.EINTR: - raise if errno_ == errno.ECHILD: break + if errno_ != errno.EINTR: + raise return res def run(self, pm): diff --git a/debian/changelog b/debian/changelog index 6babe14c..6b0c2297 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low the same behavior as in 0.7.92 * apt/package.py: - Use the source version instead of the binary version in fetch_source(). + * apt/progress/__init__.py: + - Correctly ignore ECHILD by checking before EINTR (Closes: #546007) -- Julian Andres Klode Fri, 28 Aug 2009 14:38:06 +0200 -- cgit v1.2.3 From 2a5bb5071e4046773407bfb47511c72dcd1aa887 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 15 Sep 2009 15:17:13 +0200 Subject: apt/cache.py: Add raiseOnError option to Cache.update() (Closes: #545474) --- apt/cache.py | 11 +++++++++-- debian/changelog | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index bb944041..fa6c404c 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, pulseInterval=0): + def update(self, fetchProgress=None, pulseInterval=0, raiseOnError=False): " run the equivalent of apt-get update " lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" lock = apt_pkg.GetLock(lockfile) @@ -280,7 +280,14 @@ class Cache(object): try: if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() - return self._cache.Update(fetchProgress, self._list, pulseInterval) + res = self._cache.Update(fetchProgress, self._list, pulseInterval) + + if res == 2 and raiseOnError: + raise FetchCancelledException() + elif res == 1 and raiseOnError: + raise FetchFailedException() + else: + return res finally: os.close(lock) diff --git a/debian/changelog b/debian/changelog index 51946519..24ce6245 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low * python/depcache.cc: - Make ActionGroups context managers so apt.Cache.actiongroup() has the same behavior as in 0.7.92 + * apt/cache.py: + - Add raiseOnError option to Cache.update() (Closes: #545474) * apt/package.py: - Use the source version instead of the binary version in fetch_source(). * apt/progress/__init__.py: -- cgit v1.2.3 From be85eeaeadf8b93021413ab7ed79e639b65102a6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 15 Sep 2009 15:19:21 +0200 Subject: Release 0.7.13.3 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 24ce6245..e22014a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.13.3) UNRELEASED; urgency=low +python-apt (0.7.13.3) unstable; urgency=low [ Michael Vogt ] * apt/cache.py: @@ -23,7 +23,7 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low * apt/progress/__init__.py: - Correctly ignore ECHILD by checking before EINTR (Closes: #546007) - -- Julian Andres Klode Fri, 28 Aug 2009 14:38:06 +0200 + -- Julian Andres Klode Tue, 15 Sep 2009 15:18:45 +0200 python-apt (0.7.13.2) unstable; urgency=low -- cgit v1.2.3