[Yum] Re: Only cosmetics: http referrer?
Axel Thimm
Axel.Thimm at physik.fu-berlin.de
Thu Jun 19 00:21:45 UTC 2003
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:
--
Axel.Thimm at physik.fu-berlin.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.baseurl.org/pipermail/yum/attachments/20030619/94b8f06d/attachment-0001.pgp
More information about the Yum
mailing list