[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to retrieve the pacakge URI and architecture from python-apt



On Sun, Mar 29, 2009 at 10:39:01PM +0200, A Mennucc wrote:
> hi,
> 
> in my program 'debdelta-upgrade', I need to see which debian packages
> need to be upgrade, and for each on, know the complete URI , somthing as
>   http://ftp.it.debian.org/debian/pool/main/m/memstat/memstat_0.5_i386.deb
> 
> I was helped by M.Vogt with a snippet that s in this email; but
> with the new python-apt in unstable, the following snippet stopped working.
> 
> How do I change it? (I tried to read the docs, but I do not know enaough
> of APT )
> 

This is the code you can use from now on (or you can drop 0.7.8 support
completely). Please also note the p.candidateOrigin, etc. have been deprecated
in 0.7.9 and you should update debdelta at sometime (before the release of
Squeeze), so the deprecated interfaces may be removed afterwards.

I tried to write a patch for getting debdelta working again, but you too many
lines end with whitespace, which confuses my editor a bit.

-- Code:
      try:
        # >= 0.7.10
        deb_uri = p.candidate.uri
      except AttributeError:
        # <= 0.7.8 (from debdelta)
        p._lookupRecord(True)
        dpkg_params = apt_pkg.ParseSection(p._records.Record)
        cand = p._depcache.GetCandidateVer(p._pkg)
        deb_path=dpkg_params['Filename']
        for (packagefile,i) in cand.FileList:
          indexfile = cache._list.FindIndex(packagefile)
          if indexfile:
            deb_uri=indexfile.ArchiveURI(deb_path)
            break

-- 
Julian Andres Klode  - Free Software Developer
   Debian Developer  - Contributing Member of SPI
   Ubuntu Member     - Fellow of FSFE

Website: http://jak-linux.org/   XMPP: juliank@jabber.org
Debian:  http://www.debian.org/  SPI:  http://www.spi-inc.org/
Ubuntu:  http://www.ubuntu.com/  FSFE: http://www.fsfe.org/

Attachment: signature.asc
Description: Digital signature


Reply to: