Re: Support broken for python2.3 (and RHEL 4) ?

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

 



On 03/16/2010 09:18 AM, External DI PIETRO Nicolas (CAMPUS) wrote:

The question is, is func meant to be run on python2.3 or does the
support for (old) python2.3 dropped ?

I do not know if it is intentional but with 0.25 python 2.3 support broke.

Attached is a patch which will add python 2.3 support. We are applying it inside our .spec file:

%if 0%{?rhel} == 4
%patch3 -p1 -b .py23
%endif

The patch might be a bit hackish and I would not suggest using it on machines which have a python 2.4 package installed. Otherwise however, it works fine.

cheers,
 andreas

--
Andreas Thienemann               Unix Systems Administrator
Amsterdam, The Netherlands   andreas.thienemann@xxxxxxxxxxx
http://www.booking.com          tel external +31 20 7156 00
                                    tel internal (7207)3006

--- func/func/logger.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/logger.py	2010-01-28 03:01:17.000000000 +0100
@@ -160,7 +160,6 @@
 
 class LogFactory(object):
     
-    @staticmethod
     def get_instance(type=STANDART_LOGGER,app_name="direct_log",log_place=None):
         if type == STANDART_LOGGER:
             if not log_place:
@@ -177,3 +176,5 @@
             return logger
         else:
             return None
+    get_instance = staticmethod(get_instance)
+
--- func/func/utils.py.py23	2010-01-28 03:01:19.000000000 +0100
+++ func/func/utils.py	2010-01-28 03:01:25.000000000 +0100
@@ -161,7 +161,10 @@
         except Exception,e:
             #something went wrong so we return the normal reference value
             return function_ref
-        return getattr(fresh_instance,function_ref.__name__)
+       	try:
+            return getattr(fresh_instance,function_ref.__name__)
+	except AttributeError:
+            return getattr(fresh_instance,function_ref._name_)
 
 def should_log(args):
     if args and type(args[len(args)-1]) == dict and args[len(args)-1].has_key('__logger__') and args[len(args)-1]['__logger__'] == True:
--- func/func/minion/server.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/server.py	2010-01-28 03:01:17.000000000 +0100
@@ -102,7 +102,6 @@
     
     
     import func.minion.modules.func_module as fm
-    @fm.findout
     def grep(self,word):
         """
         Finding the wanted word
@@ -125,6 +124,7 @@
                 return_dict[self.list_methods]=m
 
         return return_dict
+    grep = fm.findout(grep)
 
 
     def inventory(self):
--- func/func/minion/modules/hardware.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/hardware.py	2010-01-28 03:01:17.000000000 +0100
@@ -67,7 +67,6 @@
             del data["bogomips"]
         return data
 
-    @func_module.findout
     def grep(self,word):
         """
         Find something in hardware info 
@@ -97,6 +96,7 @@
         
         #get the final result
         return result
+    grep = func_module.findout(grep)
 
 
 
--- func/func/minion/modules/filetracker.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/filetracker.py	2010-01-28 03:01:17.000000000 +0100
@@ -198,7 +198,6 @@
 
     #==========================================================
     
-    @func_module.findout
     def grep(self, word):
         """
         Some search utility about tracked files
@@ -215,6 +214,7 @@
                     results[self.inventory].append(res)
             
         return results
+    grep = func_module.findout(grep)
     
     
     def __sumfile(self, fobj):
--- func/func/minion/modules/fact.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/fact.py	2010-01-28 03:01:17.000000000 +0100
@@ -62,7 +62,6 @@
                 return method() 
         return {}
     
-    @func_module.findout
     def grep(self, word):
         """
         Get some info about facts
@@ -86,4 +85,5 @@
 
         #the final collected stuff here
         return result
+    grep = func_module.findout(grep)
         
--- func/func/minion/modules/mount.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/mount.py	2010-01-28 03:01:17.000000000 +0100
@@ -85,7 +85,6 @@
         return self.list()
 
     
-    @func_module.findout
     def grep(self,word):
         """
         Get some info about mounted devices
@@ -99,6 +98,7 @@
                     if m_k.lower().find(word)!=-1 or m_v.lower().find(word)!=-1:
                         results[self.list].append({m_k:m_v})
         return results
+    grep = func_module.findout(grep)
                     
         
 
--- func/func/minion/modules/process.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/process.py	2010-01-28 03:01:17.000000000 +0100
@@ -224,7 +224,6 @@
     def loadavg(self):
         return open("/proc/loadavg", "r").readline().strip().split(" ")
 
-    @func_module.findout
     def grep(self, word):
         """
         Some grep info about :
@@ -251,6 +250,7 @@
         
         
         return results
+    grep = func_module.findout(grep)
     
 
     def register_method_args(self):
--- func/func/minion/modules/service.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/service.py	2010-01-28 03:01:17.000000000 +0100
@@ -55,7 +55,6 @@
             "enabled" : self.get_enabled()
         }
 
-    @func_module.findout
     def grep(self,word):
         """
         Dig for some useful info in that module ...
@@ -77,6 +76,7 @@
                 final_dict[self.get_running].append(e)
 
         return final_dict
+    grep = func_module.findout(grep)
         
 
 
--- func/func/minion/modules/sysctl.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/sysctl.py	2010-01-28 03:01:17.000000000 +0100
@@ -31,7 +31,6 @@
     def set(self, name, value):
         return self.__run("/sbin/sysctl -w %s=%s" % (name, value))
 
-    @func_module.findout
     def grep(self, word):
         """
         Grep info from sysctl
@@ -44,6 +43,7 @@
                 results[self.list].append(res)
         
         return results
+    grep = func_module.findout(grep)
 
             
     def register_method_args(self):
--- func/func/minion/modules/yumcmd.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/yumcmd.py	2010-01-28 03:01:17.000000000 +0100
@@ -71,7 +71,6 @@
 
         return map(str, pkg_list)
     
-    @func_module.findout
     def grep(self, word):
         """
         Grep info from module
@@ -81,6 +80,7 @@
         results[self.check_update].extend([res for res in update_res if res.lower().find(word)!=-1])
         
         return results
+    grep = func_module.findout(grep)
     
     def register_method_args(self):
         """
--- func/func/minion/modules/networktest.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/networktest.py	2010-01-28 03:01:17.000000000 +0100
@@ -54,7 +54,6 @@
         sock.close()
         return [0, "connection to %s:%s succeeded" % (host, port)]
 
-    @func_module.findout
     def grep(self, word):
         """
         Grep some info from grep test
@@ -70,6 +69,7 @@
                 results[self.netstat].append(res)
         
         return results
+    grep = func_module.findout(grep)
 
     def __args_to_list(self, args):
         return [arg for arg in args]
--- func/func/minion/modules/func_module.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/func_module.py	2010-01-28 03:01:17.000000000 +0100
@@ -44,7 +44,10 @@
     
     #a hack for get_arg_methods
     wrapper.overriden_args = inspect.getargspec(fn)
-    wrapper.__name__ = fn.__name__
+    try:
+        wrapper.__name__ = fn.__name__
+    except:
+        wrapper._name_ = fn.__name__
     return wrapper
 
 
--- func/func/minion/modules/smart.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/smart.py	2010-01-28 03:01:17.000000000 +0100
@@ -46,7 +46,6 @@
 
         return (cmd.returncode, results)
 
-    @func_module.findout
     def grep(self, word):
         """
         grep some info from grep
@@ -59,6 +58,7 @@
                 if res.lower().find(word)!=-1:
                     results[self.info].append(res)
         return results
+    grep = func_module.findout(grep)
 
     def register_method_args(self):
         """
--- func/func/minion/modules/users.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/users.py	2010-01-28 03:01:17.000000000 +0100
@@ -479,7 +479,6 @@
     """Returns group info for all users on the target system(s)."""
     return self.groups_inventory()
   
-  @func_module.findout
   def grep(self, word):
     """
     Grep some info from user_list and
@@ -496,6 +495,7 @@
     results[self.user_list].extend([res for res in user_list if res.lower().find(word)!=-1])
     results[self.group_list].extend([res for res in group_list if res.lower().find(word)!=-1])
     return results
+  grep = func_module.findout(grep)
 
 # CONVERSION METHODS
   def user_to_uid(self,user):
--- func/func/minion/modules/rpms.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/minion/modules/rpms.py	2010-01-28 03:01:17.000000000 +0100
@@ -45,7 +45,6 @@
                 results.append([name, epoch, version, release, arch])
         return results
 
-    @func_module.findout
     def grep(self, word):
         """
         Grep some info from packages we got from
@@ -59,6 +58,7 @@
                 results[self.inventory].append(res)
         
         return results
+    grep = func_module.findout(grep)
 
     def verify(self, pattern='', flatten=True):
         """
--- func/func/module_loader.py.py23	2010-01-27 23:25:25.000000000 +0100
+++ func/func/module_loader.py	2010-01-28 03:01:17.000000000 +0100
@@ -108,13 +108,15 @@
             # A module that raises an ImportError is (for now) simply not loaded.
             errmsg = _("Import error while loading %s module: %s")
             log.warning(errmsg % (mod_imp_name, e))
-            log.warning("%s" % traceback.format_exc())
+            etype, value, tb = sys.exc_info()
+            log.warning(traceback.format_exception(etype, value, tb))
             bad_mods[mod_imp_name] = True
             continue
         except:
             errmsg = _("Could not load %s module")
             log.warning(errmsg % (mod_imp_name))
-            log.warning("%s" % traceback.format_exc())
+            etype, value, tb = sys.exc_info()
+            log.warning(traceback.format_exception(etype, value, tb))
             bad_mods[mod_imp_name] = True
             continue
 
_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

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

  Powered by Linux