summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-12-05 18:34:01 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-12-05 18:34:01 +0000
commitbc7a0801357ecb20535efc3aefad1832274bb29c (patch)
treed51fd91edc20bad5f6d1f51efa7449838c24c654
parentc89b8408c0115e9fccdd4bfe180e93eb746b12cd (diff)
downloadpython-apt-bc7a0801357ecb20535efc3aefad1832274bb29c.tar.gz
* added PkgSourceList.GetIndexes(); rewrote apt.cache.update() to use it
-rw-r--r--apt/cache.py54
-rw-r--r--debian/changelog3
-rw-r--r--python/sourcelist.cc17
3 files changed, 54 insertions, 20 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 342dbfb5..973ffea5 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -112,24 +112,7 @@ class Cache(object):
self._depcache.Upgrade(distUpgrade)
self.cachePostChange()
- def update(self, fetchProgress=None, opProgress=None):
- if(opProgress != None):
- self._cache.Update(fetchProgress, opProgress);
- else:
- self._cache.Update(fetchProgress);
-
- def _fetchArchives(self, fetcher, pm, fetchProgress):
- """ fetch the needed archives """
-
- # get lock
- lockfile = apt_pkg.Config.FindDir("Dir::Cache::Archives") + "lock"
- lock = apt_pkg.GetLock(lockfile)
- if lock < 0:
- raise IOError, "Failed to lock %s" % lockfile
-
- # this may as well throw a SystemError exception
- if not pm.GetArchives(fetcher, self._list, self._records):
- return False
+ def _runFetcher(self, fetcher):
# do the actual fetching
res = fetcher.Run()
if res == fetcher.ResultFailed:
@@ -140,7 +123,8 @@ class Cache(object):
transient = False
errMsg = ""
for item in fetcher.Items:
- if item.StatDone and item.Complete:
+ print item
+ if item.Status == item.StatDone:
continue
if item.StatIdle:
transient = True
@@ -151,10 +135,42 @@ class Cache(object):
# we raise a exception if the download failed
if failed:
raise IOError, errMsg
+ return res
+
+ def _fetchArchives(self, fetcher, pm, fetchProgress):
+ """ fetch the needed archives """
+ # get lock
+ lockfile = apt_pkg.Config.FindDir("Dir::Cache::Archives") + "lock"
+ lock = apt_pkg.GetLock(lockfile)
+ if lock < 0:
+ raise IOError, "Failed to lock %s" % lockfile
+
+ # this may as well throw a SystemError exception
+ if not pm.GetArchives(fetcher, self._list, self._records):
+ return False
+ # now run the fetcher, throw exception if something fails to be
+ # fetched
+ res = self._runFetcher(fetcher)
+
# cleanup
os.close(lock)
return res
+
+ def update(self, fetchProgress=None):
+ lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock"
+ lock = apt_pkg.GetLock(lockfile)
+ if lock < 0:
+ raise IOError, "Failed to lock %s" % lockfile
+ 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
+ res = self._runFetcher(fetcher)
+ return res
def installArchives(self, pm, installProgress):
installProgress.startUpdate()
diff --git a/debian/changelog b/debian/changelog
index bda57c52..99201581 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,8 @@ python-apt (0.6.16) unstable; urgency=low
* added GetPkgAcqFile to queue individual file downloads with the
system
- * added Package.downloadable
+ * added SourceList.GetIndexes()
+ * rewrote apt.cache.update() to use the improved aquire interface
-- Michael Vogt <michael.vogt@ubuntu.com> Thu, 1 Dec 2005 14:01:39 +0100
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index 4eed21a7..497731c0 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -36,10 +36,27 @@ static PyObject *PkgSourceListReadMainList(PyObject *Self,PyObject *Args)
return HandleErrors(Py_BuildValue("b",res));
}
+static char *doc_PkgSourceListGetIndexes = "Load the indexes into the fetcher";
+static PyObject *PkgSourceListGetIndexes(PyObject *Self,PyObject *Args)
+{
+ pkgSourceList *list = GetCpp<pkgSourceList*>(Self);
+
+ PyObject *pyFetcher;
+
+ if (PyArg_ParseTuple(Args, "O!",&PkgAcquireType,&pyFetcher) == 0)
+ return 0;
+
+ pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyFetcher);
+ bool res = list->GetIndexes(fetcher);
+
+ return HandleErrors(Py_BuildValue("b",res));
+}
+
static PyMethodDef PkgSourceListMethods[] =
{
{"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex},
{"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList},
+ {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListReadMainList},
{}
};