rhn-applet patch [was Re: [rhn-users] up2date...]

Bob Drzyzgula redhat at drzyzgula.org
Fri Mar 19 15:13:40 UTC 2004


On Thu, Mar 18, 2004 at 07:31:33PM -0500, Todd Warner wrote:
> 
> Patches gladly accepted. Send 'em our way and we'll take a look-see.
> rhnlib and up2date are GPLed software so... there you go.
> 
> Definately sounds like something is funky though. I will make sure the
> right people know about it.
> 
> -- 
> ____________
>  /odd Warner                                    <taw@{redhat,pobox}.com>
>           Bit Twiddler - Operation Cheetah Flip - Red Hat Inc.
> ---------------------gpg info in the message headers--------------------
> "But when you think about it, it's mostly the bad decisions we make
>  that change our lives. Good ones just get you home safely." -Chris Bliss

rhn-applet patch:

# This is a patch against RHEL 3.0WS rhn-applet-2.0.12
#
# This patch will add support for a configurable http user agent string
# in the RHN toolbar applet. It relies on parallel patches to rhnlib
# and up2date. Affected source files are
#
#   rhn_applet.py
#   rhn_applet_model.py
#   rhn_applet_rpc.py
#
# This patch does not enable the user agent string to be configured via the
# applet's GUI configuration dialog; configuration can only be done in
# the applet's configuration file, e.g. ~/.rhn-applet.conf
#
# This patch is provided as is, with no warranty.
#
# Bob Drzyzgula
# redhat at drzyzgula.org
#
diff -r -U 3 rhn-applet-2.0.12.orig/rhn_applet_model.py rhn-applet-2.0.12.patched/rhn_applet_model.py
--- rhn-applet-2.0.12.orig/rhn_applet_model.py	2002-09-03 03:23:11.000000000 -0400
+++ rhn-applet-2.0.12.patched/rhn_applet_model.py	2004-03-17 10:34:08.000000000 -0500
@@ -40,6 +40,7 @@
         self.__proxy__ = ''
         self.__proxy_username__ = ''
         self.__proxy_password__ = ''
+        self.__user_agent_string__ = None
         
         self.__arch__ = os.uname()[4]
 
@@ -62,13 +63,14 @@
         self.__mode__ = mode
         self.__cert__ = cert
 
-    def set_proxy(self, proxy, u, p):
+    def set_proxy(self, proxy, u, p, a):
         self.__proxy__ = proxy
         self.__proxy_username__ = u
         self.__proxy_password__ = p
+        self.__user_agent_string__ = a
 
         if self.__rpc_server__:
-            self.__rpc_server__.set_proxy(proxy, u, p)
+            self.__rpc_server__.set_proxy(proxy, u, p, a)
 
     def is_package_ignored(self, name):
         if self.__ignored_packages__.has_key(name):
@@ -202,7 +204,8 @@
                                                self.__cert__,
                                                self.__proxy__,
                                                self.__proxy_username__,
-                                               self.__proxy_password__)
+                                               self.__proxy_password__,
+                                               self.__user_agent_string__)
 
         if self.__kernel_running__ != None and self.__rpc_server__ and rpm.latest_installed_packages():
             return 1
diff -r -U 3 rhn-applet-2.0.12.orig/rhn_applet.py rhn-applet-2.0.12.patched/rhn_applet.py
--- rhn-applet-2.0.12.orig/rhn_applet.py	2003-09-06 19:40:14.000000000 -0400
+++ rhn-applet-2.0.12.patched/rhn_applet.py	2004-03-17 10:34:08.000000000 -0500
@@ -216,13 +216,14 @@
         self.proxy = rhn_utils.get_user_config("httpProxy")
         self.proxy_username = rhn_utils.get_user_config("proxyUser")
         self.proxy_password = rhn_utils.get_user_config("proxyPassword")
+        self.user_agent_string = rhn_utils.get_user_config("userAgent")
         
         self.model = rhnAppletModelGUI(self.refresh_callback,
                                        rhn_utils.get_config("server_url"),
                                        rhn_utils.get_config("uuid"),
                                        rhn_utils.get_config("use_ca_cert"))
 
-        self.model.set_proxy(self.proxy, self.proxy_username, self.proxy_password)
+        self.model.set_proxy(self.proxy, self.proxy_username, self.proxy_password, self.user_agent_string)
 
         self.animator = None
         self.client = None
@@ -411,6 +412,9 @@
                 params.append(self.proxy_username)
                 params.append("--proxyPassword")
                 params.append(self.proxy_password)
+            if self.user_agent_string:
+                params.append("--userAgent")
+                params.append(self.user_agent_string)
             
         pid = os.fork()
         if not pid:
@@ -600,13 +604,15 @@
         rhn_utils.set_user_config("httpProxy", self.proxy)
         rhn_utils.set_user_config("proxyUser", self.proxy_username)
         rhn_utils.set_user_config("proxyPassword", self.proxy_password)
+        rhn_utils.set_user_config("userAgent", self.user_agent_string)
         
-        self.model.set_proxy(self.proxy, self.proxy_username, self.proxy_password)
+        self.model.set_proxy(self.proxy, self.proxy_username, self.proxy_password, self.user_agent_string)
         
-    def set_proxy(self, proxy = '', u = '', p = ''):
+    def set_proxy(self, proxy = '', u = '', p = '', a = None):
         self.proxy = proxy
         self.proxy_username = u
         self.proxy_password = p
+        self.user_agent_string = a
        
     def notice_window_closed(self):
         rhn_utils.log_debug("closed")
diff -r -U 3 rhn-applet-2.0.12.orig/rhn_applet_rpc.py rhn-applet-2.0.12.patched/rhn_applet_rpc.py
--- rhn-applet-2.0.12.orig/rhn_applet_rpc.py	2002-12-03 10:47:34.000000000 -0500
+++ rhn-applet-2.0.12.patched/rhn_applet_rpc.py	2004-03-17 10:34:08.000000000 -0500
@@ -28,7 +28,7 @@
      rhnAppletNetworkException
 
 class rhnAppletRPC:
-    def __init__(self, url, refresh_callback, uuid, release, arch, cert, proxy_url, proxy_username, proxy_password):
+    def __init__(self, url, refresh_callback, uuid, release, arch, cert, proxy_url, proxy_username, proxy_password, user_agent_string):
         self.__arch__ = arch
         self.__release__ = release
         
@@ -40,6 +40,7 @@
         self.__proxy_url__ = proxy_url
         self.__proxy_username__ = proxy_username
         self.__proxy_password__ = proxy_password
+        self.__user_agent_string__ = user_agent_string
 
         self.__latest_packages__ = []
         self.__latest_packages_mtime__ = 0
@@ -48,14 +49,16 @@
 
         self.get_data_store()
 
-    def set_proxy(self, proxy_url, proxy_username, proxy_password):
+    def set_proxy(self, proxy_url, proxy_username, proxy_password, user_agent_string):
         self.__proxy_url__ = self.__proxy_username__ = self.__proxy_password__ = ''
+        self.__user_agent_string__ = None
         
         if proxy_url:
             self.__proxy_url__ = proxy_url
             if proxy_username:
                 self.__proxy_username__ = proxy_username
                 self.__proxy_password__ = proxy_password
+                self.__user_agent_string__ = user_agent_string
         
     def create_server(self):
         options = { "uri" : self.__server_url__,
@@ -66,6 +69,8 @@
             if self.__proxy_username__:
                 options["username"] = self.__proxy_username__
                 options["password"] = self.__proxy_password__
+            if self.__user_agent_string__:
+                options["userAgent"] = self.__user_agent_string__
 
         s = apply(rpclib.Server, [], options)
 





More information about the rhn-users mailing list