diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-12-05 18:34:01 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-12-05 18:34:01 +0000 |
| commit | bc7a0801357ecb20535efc3aefad1832274bb29c (patch) | |
| tree | d51fd91edc20bad5f6d1f51efa7449838c24c654 /apt | |
| parent | c89b8408c0115e9fccdd4bfe180e93eb746b12cd (diff) | |
| download | python-apt-bc7a0801357ecb20535efc3aefad1832274bb29c.tar.gz | |
* added PkgSourceList.GetIndexes(); rewrote apt.cache.update() to use it
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/cache.py | 54 |
1 files changed, 35 insertions, 19 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() |
