Re: building plugin that simulates repository...

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

 



On Friday, October 14, 2011, James Antill wrote:
> >> > File "/usr/lib/python2.4/site-packages/yum/packages.py", line 1145, in
> >> > __getattr__
> >> > 
> >> >     return self.hdr[thing]
> >> > 
> >> > KeyError: 'unknown header tag'
> 
> [...]
> 
> >>  Change the code to what is done upstream (gives the attribute name),
> >> 
> >> will help debugging a lot.
> > 
> > you got me there. What do you mean? So far I'm stuck trying to figure out
> > what the hdr['tag'] should include - from what I've seen _populatePrco()
> > is supposed to do exactly that, but apparently it doesn't.
> 
>  This is __getattr__ from current upstream:
> 
>     def __getattr__(self, thing):
>         #FIXME - if an error - return AttributeError, not KeyError
>         # ONLY FIX THIS AFTER THE API BREAK
>         if thing.startswith('__') and thing.endswith('__'):
>             # If these existed, then we wouldn't get here ...
>             # So these are missing.
>             raise AttributeError, "%s has no attribute %s" % (self, thing)
>         try:
>             return self.hdr[thing]
>         except KeyError:
>             #  Note above, API break to fix this ... this at least is a
> nicer # msg. so we know what we accessed that is bad.
>             raise KeyError, "%s has no attribute %s" % (self, thing)
>         except ValueError:
>             #  Note above, API break to fix this ... this at least is a
> nicer # msg. so we know what we accessed that is bad.
>             raise ValueError, "%s has no attribute %s" % (self, thing)

thanks for the reminder to do that. Now I've got things moving!

ended up with "enhanced" CPacManPackage class:

class CPacManPackage(YumHeaderPackage):$
    def __init__(self,repo,hdr):$
        YumHeaderPackage.__init__(self,repo,hdr)$
        self.pkgid = self.hdr[rpm.RPMTAG_SHA1HEADER]$
        if not self.pkgid:$
            self.pkgid = "%s.%s" %(self.hdr['name'], self.hdr['buildtime'])$
        self.id=self.pkgid$
        self.pkgKey = self.__hash__()$

and had to add things to CPacManRepo::__init_sack code:

            ypkg=CPacManPackage(self, hdr)$
            ypkg._populatePrco()$
            ypkg.basepath='file://'+pkg['path']$
            ypkg.relativepath=pkg['package_name']$

now I have working transactions integrating CPacMan repos with yum and have to 
polish details, but that is minor in comparison to all of the above. Once I 
figure it all out and clean things up a bit I can submit back if not code to 
the core than at least some more examples for people to use and save some poor 
soul days and weeks of aggravation ;)

> > tmprepo is where I've got the "inspiration" but turned out it was
> > creating temp files on a disk (in other words being a bit "hackish").
> 
>  Yeh, it's not great (relies on createrepo etc.) ... but it works. If
> you create a real "dir. repo" then it'd probably move to using that
> pretty quickly :)

as it stands tmprepo while being an inspiration and glimmer of hope is not 
needed after all. Now that I have much more seemless integration without extra 
artefacts I can concentrate on functions :) 

James, thanks for your help.

-- 
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245
---
Confidence is what you have before you understand the problem
    Woody Allen

When in trouble when in doubt run in circles scream and shout 
     http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=19330

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Yum mailing list
Yum@xxxxxxxxxxxxxxxxx
http://lists.baseurl.org/mailman/listinfo/yum

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux