diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-01-18 16:57:57 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-01-18 16:57:57 +0100 |
| commit | abfffe610b0f5256117a6af165ee182bbc60b6a5 (patch) | |
| tree | bd58c4a267e6e3fb677e76d06c8a13fa3451119c /python | |
| parent | 46298fbf3cb7ff1e7cae23c0f4de227979add160 (diff) | |
| parent | dbf6dd4e8d576eb8516b11e8d8861113bf4dfc52 (diff) | |
| download | python-apt-abfffe610b0f5256117a6af165ee182bbc60b6a5.tar.gz | |
* use the new apt ListUpdate() code
* add example in doc/examples/update.py
Diffstat (limited to 'python')
| -rw-r--r-- | python/cache.cc | 50 |
1 files changed, 9 insertions, 41 deletions
diff --git a/python/cache.cc b/python/cache.cc index aa4d9ffc..36e49710 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -20,10 +20,13 @@ #include <apt-pkg/packagemanager.h> #include <apt-pkg/pkgsystem.h> #include <apt-pkg/sourcelist.h> +#include <apt-pkg/algorithms.h> #include <Python.h> #include "progress.h" +class pkgSourceList; + /*}}}*/ struct PkgListStruct { @@ -76,53 +79,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 = 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) |
