On Wed, 2003-06-18 at 20:21, Axel Thimm wrote: > On Thu, Jun 19, 2003 at 02:19:42AM +0200, Axel Thimm wrote: > > Axel Thimm wrote: > > > looking at my stats I see yum come up as "Python-urllib/2.0a1", would you like > > > to change that to something like yum/someversionhere? > > > > Here is a small patch, that changes the User-Agent to "Yum/1.98". It > > wasn't as trivial as I hoped it were, but the result is quite compact > > and comprehendable. > > > > This is my first python code, treat with care ;) > > --- yum-1.98/urlgrabber.py.agent 2003-06-01 05:33:33.000000000 +0200 > +++ yum-1.98/urlgrabber.py 2003-06-17 22:24:52.000000000 +0200 > @@ -15,6 +15,16 @@ > import urllib > urllib2 = urllib > > +class MyOpenerDirector(urllib2.OpenerDirector): > + def __init__(self): > + self.addheaders = [('User-agent', "Yum/1.98")] > + # manage the individual handlers > + self.handlers = [] > + self.handle_open = {} > + self.handle_error = {} > + > +urllib2.OpenerDirector = MyOpenerDirector > + > try: > from httplib import HTTPException > except ImportError, msg: spiffy. done. - cept I made it Yum/2.x so I wouldn't have to screw around with the version string so much ;) -sv