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

[Freeipa-devel] [PATCH] New patch for compat



This addresses Karl's concerns about CalledProcessError being defined everywhere.

rob
# HG changeset patch
# User rcritten redhat com
# Date 1196455982 18000
# Node ID 7b8043d1ebcb53e5ef8e9b2a78faafb0dd32e1bd
# Parent  12ed744db002d0b08f8036f91c1eddf2e1b75d2d
Compatibility changes to work on RHEL 5 with python 2.4

diff -r 12ed744db002 -r 7b8043d1ebcb ipa-admintools/ipa-adduser
--- a/ipa-admintools/ipa-adduser	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-admintools/ipa-adduser	Fri Nov 30 15:53:02 2007 -0500
@@ -228,7 +228,7 @@ def main():
     # Set the User's password
     if password is not None:
         try:
-            client.modifyPassword(principal, None, password)
+            client.modifyPassword(principal, '', password)
         except ipa.ipaerror.IPAError, e:
             print "User added but setting the password failed."
             print "%s" % (e.message)
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-admintools/ipa-passwd
--- a/ipa-admintools/ipa-passwd	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-admintools/ipa-passwd	Fri Nov 30 15:53:02 2007 -0500
@@ -98,7 +98,7 @@ def main():
 
     try:
         client = ipaclient.IPAClient()
-        client.modifyPassword(principal, None, password)
+        client.modifyPassword(principal, '', password)
     except xmlrpclib.Fault, fault:
         if fault.faultCode == errno.ECONNREFUSED:
             print "The IPA XML-RPC service is not responding."
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-client/configure.ac
--- a/ipa-client/configure.ac	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-client/configure.ac	Fri Nov 30 15:53:02 2007 -0500
@@ -1,4 +1,4 @@ AC_PREREQ(2.59c)
-AC_PREREQ(2.59c)
+AC_PREREQ(2.59)
 AC_INIT([ipa-client],
         [0.5.0],
         [https://hosted.fedoraproject.org/projects/freeipa/newticket])
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-python/ipautil.py
--- a/ipa-python/ipautil.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-python/ipautil.py	Fri Nov 30 15:53:02 2007 -0500
@@ -33,6 +33,22 @@ import re
 import re
 import xmlrpclib
 import datetime
+try:
+    from subprocess import CalledProcessError
+    class CalledProcessError(subprocess.CalledProcessError):
+        def __init__(self, returncode, cmd):
+            super(CalledProcessError, self).__init__(returncode, cmd)
+except ImportError:
+    # Python 2.4 doesn't implement CalledProcessError
+    class CalledProcessError(Exception):
+        """This exception is raised when a process run by check_call() returns
+        a non-zero exit status. The exit status will be stored in the
+        returncode attribute."""
+        def __init__(self, returncode, cmd):
+            self.returncode = returncode
+            self.cmd = cmd
+        def __str__(self):
+            return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
 
 def realm_to_suffix(realm_name):
     s = realm_name.split(".")
@@ -63,7 +79,7 @@ def run(args, stdin=None):
     logging.info(stderr)
 
     if p.returncode != 0:
-        raise subprocess.CalledProcessError(p.returncode, ' '.join(args))
+        raise self.CalledProcessError(p.returncode, ' '.join(args))
 
 def file_exists(filename):
     try:
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/configure.ac
--- a/ipa-server/configure.ac	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/configure.ac	Fri Nov 30 15:53:02 2007 -0500
@@ -1,4 +1,4 @@ AC_PREREQ(2.59c)
-AC_PREREQ(2.59c)
+AC_PREREQ(2.59)
 AC_INIT([ipa-server],
         [0.5],
         [https://hosted.fedoraproject.org/projects/freeipa/newticket])
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipa-gui/ipagui/forms/delegate.py
--- a/ipa-server/ipa-gui/ipagui/forms/delegate.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipa-gui/ipagui/forms/delegate.py	Fri Nov 30 15:53:02 2007 -0500
@@ -43,7 +43,7 @@ aci_checkbox_attrs = [(field.name, field
 
 aci_name_to_label = dict(aci_checkbox_attrs)
 
-class DelegateFields():
+class DelegateFields(object):
     name = widgets.TextField(name="name", label="Delegation Name")
 
     source_group_dn = widgets.HiddenField(name="source_group_dn")
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipa-gui/ipagui/forms/group.py
--- a/ipa-server/ipa-gui/ipagui/forms/group.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipa-gui/ipagui/forms/group.py	Fri Nov 30 15:53:02 2007 -0500
@@ -2,7 +2,7 @@ from turbogears import validators, widge
 from turbogears import validators, widgets
 from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
 
-class GroupFields():
+class GroupFields(object):
     cn = widgets.TextField(name="cn", label="Name")
     gidnumber = widgets.TextField(name="gidnumber", label="GID")
     description = widgets.TextField(name="description", label="Description")
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
--- a/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py	Fri Nov 30 15:53:02 2007 -0500
@@ -1,9 +1,9 @@ import turbogears
 import turbogears
 from turbogears import validators, widgets
 
-class IPAPolicyFields():
+class IPAPolicyFields(object):
     # From cn=ipaConfig
-    ipausersearchfields =  widgets.TextField(name="ipausersearchfields", label="User Search Fields")
+    ipausersearchfields =  widgets.TextField(name="ipausersearchfields", label="User Search Fields", attrs=dict(size=50))
     ipagroupsearchfields =  widgets.TextField(name="ipagroupsearchfields", label="Group Search Fields")
     ipasearchtimelimit = widgets.TextField(name="ipasearchtimelimit", label="Search Time Limit (sec.)", attrs=dict(size=6,maxlength=6))
     ipasearchrecordslimit = widgets.TextField(name="ipasearchrecordslimit", label="Search Records Limit", attrs=dict(size=6,maxlength=6))
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipa-gui/ipagui/forms/user.py
--- a/ipa-server/ipa-gui/ipagui/forms/user.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipa-gui/ipagui/forms/user.py	Fri Nov 30 15:53:02 2007 -0500
@@ -2,7 +2,7 @@ from turbogears import validators, widge
 from turbogears import validators, widgets
 from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
 
-class UserFields():
+class UserFields(object):
     givenname = widgets.TextField(name="givenname", label="Given Name")
     sn = widgets.TextField(name="sn", label="Family Name")
     cn = widgets.TextField(name="cn", label="Common Names")
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipaserver/dsinstance.py
--- a/ipa-server/ipaserver/dsinstance.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipaserver/dsinstance.py	Fri Nov 30 15:53:02 2007 -0500
@@ -29,7 +29,6 @@ import sys
 
 from ipa.ipautil import *
 import service
-
 import installutils
 
 SERVER_ROOT_64 = "/usr/lib64/dirsrv"
@@ -188,7 +187,7 @@ class DsInstance(service.Service):
             try:
                 run(args)
                 logging.debug("done adding user")
-            except subprocess.CalledProcessError, e:
+            except ipautil.CalledProcessError, e:
                 logging.critical("failed to add user %s" % e)
 
     def __create_instance(self):
@@ -206,13 +205,13 @@ class DsInstance(service.Service):
         try:
             run(args)
             logging.debug("completed creating ds instance")
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("failed to restart ds instance %s" % e)
         logging.debug("restarting ds instance")
         try:
             self.restart()
             logging.debug("done restarting ds instance")
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "failed to restart ds instance", e
             logging.debug("failed to restart ds instance %s" % e)
 
@@ -233,7 +232,7 @@ class DsInstance(service.Service):
         memberof_fd = write_tmp_file(memberof_txt)
         try:
             ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
         memberof_fd.close()
 
@@ -243,7 +242,7 @@ class DsInstance(service.Service):
         memberof_fd = write_tmp_file(memberof_txt)
         try:
             ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
         memberof_fd.close()
 
@@ -253,7 +252,7 @@ class DsInstance(service.Service):
         referint_fd = write_tmp_file(referint_txt)
         try:
             ldap_mod(referint_fd, "cn=Directory Manager", self.dm_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "Failed to load referint-conf.ldif", e
         referint_fd.close()
 
@@ -263,7 +262,7 @@ class DsInstance(service.Service):
         dna_fd = write_tmp_file(dna_txt)
         try:
             ldap_mod(dna_fd, "cn=Directory Manager", self.dm_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "Failed to load dna-conf.ldif", e
         dna_fd.close()
 
@@ -273,7 +272,7 @@ class DsInstance(service.Service):
         dna_fd = write_tmp_file(dna_txt)
         try:
             ldap_mod(dna_fd, "cn=Directory Manager", self.dm_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "Failed to configure Posix uid/gid generation with dna-posix.ldif", e
         dna_fd.close()
 
@@ -283,7 +282,7 @@ class DsInstance(service.Service):
         master_fd = write_tmp_file(master_txt)
         try:
             ldap_mod(master_fd, "cn=Directory Manager", self.dm_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "Failed to add master-entry.ldif", e
         master_fd.close()
 
@@ -295,7 +294,7 @@ class DsInstance(service.Service):
         try:
             run(args)
             logging.debug("done configuring ssl for ds instance")
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to configure ssl in ds instance %s" % e)
         
     def __add_default_layout(self):
@@ -308,7 +307,7 @@ class DsInstance(service.Service):
         try:
             run(args)
             logging.debug("done adding default ds layout")
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "Failed to add default ds layout", e
             logging.critical("Failed to add default ds layout %s" % e)
         
@@ -322,7 +321,7 @@ class DsInstance(service.Service):
         try:
             run(args)
             logging.debug("done adding/updating indeces")
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to add/update indeces %s" % str(e))
 
     def __certmap_conf(self):
@@ -347,7 +346,7 @@ class DsInstance(service.Service):
         try:
             run(args)
             logging.debug("ldappasswd done")
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             print "Unable to set admin password", e
             logging.debug("Unable to set admin password %s" % e)
 
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipaserver/httpinstance.py
--- a/ipa-server/ipaserver/httpinstance.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipaserver/httpinstance.py	Fri Nov 30 15:53:02 2007 -0500
@@ -86,7 +86,7 @@ class HTTPInstance(service.Service):
             if (os.path.exists('/usr/sbin/selinuxenabled')):
                 run(["/usr/sbin/selinuxenabled"])
                 selinux=1
-        except subprocess.CalledProcessError:
+        except ipautil.CalledProcessError:
             # selinuxenabled returns 1 if not enabled
             pass
 
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/ipaserver/krbinstance.py
--- a/ipa-server/ipaserver/krbinstance.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/ipaserver/krbinstance.py	Fri Nov 30 15:53:02 2007 -0500
@@ -33,7 +33,6 @@ import shutil
 import shutil
 
 import service
-from ipa.ipautil import *
 from ipa import ipaerror
 
 import ipaldap
@@ -47,6 +46,7 @@ import pyasn1.codec.ber.decoder
 import pyasn1.codec.ber.decoder
 import struct
 import base64
+from ipa.ipautil import *
 
 def host_to_domain(fqdn):
     s = fqdn.split(".")
@@ -245,7 +245,7 @@ class KrbInstance(service.Service):
         kerberos_fd = write_tmp_file(kerberos_txt)
         try:
             ldap_mod(kerberos_fd, "cn=Directory Manager", self.admin_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to load kerberos.ldif: %s" % str(e))
         kerberos_fd.close()
 
@@ -254,7 +254,7 @@ class KrbInstance(service.Service):
         aci_fd = write_tmp_file(aci_txt) 
         try:
             ldap_mod(aci_fd, "cn=Directory Manager", self.admin_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to load default-aci.ldif: %s" % str(e))
         aci_fd.close()
 
@@ -291,7 +291,7 @@ class KrbInstance(service.Service):
             args = ["/usr/kerberos/sbin/kdb5_ldap_util", "-D", "uid=kdc,cn=sysaccounts,cn=etc,"+self.suffix, "-w", self.kdc_password, "create", "-s", "-P", self.master_password, "-r", self.realm, "-subtrees", self.suffix, "-sscope", "sub"]
             try:
                 run(args)
-            except subprocess.CalledProcessError, e:
+            except ipautil.CalledProcessError, e:
                 print "Failed to populate the realm structure in kerberos", e
 
     def __write_stash_from_ds(self):
@@ -322,7 +322,7 @@ class KrbInstance(service.Service):
         extop_fd = write_tmp_file(extop_txt)
         try:
             ldap_mod(extop_fd, "cn=Directory Manager", self.admin_password)
-        except subprocess.CalledProcessError, e:
+        except ipautil.CalledProcessError, e:
             logging.critical("Failed to load pwd-extop-conf.ldif: %s" % str(e))
         extop_fd.close()
 
diff -r 12ed744db002 -r 7b8043d1ebcb ipa-server/xmlrpc-server/funcs.py
--- a/ipa-server/xmlrpc-server/funcs.py	Fri Nov 30 13:27:33 2007 -0500
+++ b/ipa-server/xmlrpc-server/funcs.py	Fri Nov 30 15:53:02 2007 -0500
@@ -1270,11 +1270,12 @@ class IPAServer:
 
         conn = self.getConnection(opts)
         try:
-            results = conn.getListAsync(self.basedn, self.scope,
-                filter, attr_list, 0, None, None, timelimit,
-                searchlimit)
-        except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
-            results = [0]
+            try:
+                results = conn.getListAsync(self.basedn, self.scope,
+                    filter, attr_list, 0, None, None, timelimit,
+                    searchlimit)
+            except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+                results = [0]
         finally:
             self.releaseConnection(conn)
 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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