summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/cache.py10
-rw-r--r--debian/changelog9
-rw-r--r--debian/control2
-rwxr-xr-xdoc/examples/update.py13
-rw-r--r--python/cache.cc49
5 files changed, 32 insertions, 51 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 65f3c9d9..dc2f5522 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -166,6 +166,7 @@ class Cache(object):
os.close(lock)
def update(self, fetchProgress=None):
+ " run the equivalent of apt-get update "
lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock"
lock = apt_pkg.GetLock(lockfile)
if lock < 0:
@@ -174,14 +175,7 @@ class Cache(object):
try:
if fetchProgress == None:
fetchProgress = apt.progress.FetchProgress()
- fetcher = apt_pkg.GetAcquire(fetchProgress)
- # this can throw a exception
- self._list.GetIndexes(fetcher)
- # now run the fetcher, throw exception if something fails to be
- # fetched
- if self._runFetcher(fetcher) == fetcher.ResultContinue:
- return True
- return False
+ return self._cache.Update(fetchProgress, self._list)
finally:
os.close(lock)
diff --git a/debian/changelog b/debian/changelog
index 43836914..54859732 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python-apt (0.7.5) UNRELEASED; urgency=low
+
+ * use the new CacheFile::ListUpdate() code
+ * add example in doc/examples/update.py
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Fri, 04 Jan 2008 21:17:00 +0100
+
python-apt (0.7.4) unstable; urgency=low
* apt/debfile.py:
@@ -34,7 +41,7 @@ python-apt (0.7.4) unstable; urgency=low
* data/templates/:
- update templates
- -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 29 Nov 2007 12:17:17 +0100
+ -- Michael Vogt <mvo@debian.org> Thu, 06 Dec 2007 15:35:46 +0100
python-apt (0.7.3.1) unstable; urgency=low
diff --git a/debian/control b/debian/control
index 1f583e2f..51bb064b 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,7 @@ Maintainer: APT Development Team <deity@lists.debian.org>
Uploaders: Matt Zimmerman <mdz@debian.org>, Michael Vogt <mvo@debian.org>
Standards-Version: 3.7.2.2
XS-Python-Version: all
-Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.7.0), apt-utils, python-all-dev, python-distutils-extra (>= 1.9.0), cdbs, python-central (>= 0.5), python-all-dbg
+Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.7.10), apt-utils, python-all-dev, python-distutils-extra (>= 1.9.0), cdbs, python-central (>= 0.5), python-all-dbg
XS-Vcs-Bzr: http://people.debian.org/~mvo/bzr/python-apt/debian-sid
Package: python-apt
diff --git a/doc/examples/update.py b/doc/examples/update.py
new file mode 100755
index 00000000..be7bb679
--- /dev/null
+++ b/doc/examples/update.py
@@ -0,0 +1,13 @@
+import apt
+import apt_pkg
+import os.path
+
+if __name__ == "__main__":
+ apt_pkg.Config.Set("APT::Update::Pre-Invoke::",
+ "touch /tmp/update-about-to-run")
+ apt_pkg.Config.Set("APT::Update::Post-Invoke::",
+ "touch /tmp/update-was-run")
+ c = apt.Cache()
+ res = c.update(apt.progress.TextFetchProgress())
+ print "res: ",res
+ assert(os.path.exists("/tmp/update-about-to-run"))
diff --git a/python/cache.cc b/python/cache.cc
index aa4d9ffc..2bbeb14a 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -24,6 +24,8 @@
#include <Python.h>
#include "progress.h"
+class pkgSourceList;
+
/*}}}*/
struct PkgListStruct
{
@@ -76,53 +78,18 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args)
PyObject *CacheFilePy = GetOwner<pkgCache*>(Self);
pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy);
- PyObject *pyOpProgressInst = 0;
PyObject *pyFetchProgressInst = 0;
- if (PyArg_ParseTuple(Args, "O|O", &pyFetchProgressInst,&pyOpProgressInst) == 0)
+ PyObject *pySourcesList = 0;
+ if (PyArg_ParseTuple(Args, "OO", &pyFetchProgressInst,&pySourcesList) == 0)
return 0;
- FileFd Lock;
- if (_config->FindB("Debug::NoLocking", false) == false) {
- Lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock"));
- if (_error->PendingError() == true)
- return HandleErrors();
- }
-
- pkgSourceList List;
- if(!List.ReadMainList()) {
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
- }
-
PyFetchProgress progress;
progress.setCallbackInst(pyFetchProgressInst);
+ pkgSourceList *source = GetCpp<pkgSourceList*>(pySourcesList);
+ bool res = Cache->ListUpdate(progress, *source);
- pkgAcquire Fetcher(&progress);
- if (!List.GetIndexes(&Fetcher))
- return HandleErrors();
- if (Fetcher.Run() == pkgAcquire::Failed) {
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
- }
-
-#if 0 // reopening the cache is the job of the python code now
- // doing it here is wrong and broken
- if(pyOpProgressInst != 0) {
- PyOpProgress progress;
- progress.setCallbackInst(pyOpProgressInst);
- if (Cache->Open(progress,false) == false)
- return HandleErrors();
- } else {
- OpTextProgress Prog;
- if (Cache->Open(Prog,false) == false) {
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
- }
- }
-#endif
-
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
+ PyObject *PyRes = Py_BuildValue("b", res);
+ return HandleErrors(PyRes);
}
static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args)