diff options
author | Rob Crittenden <rcritten@redhat.com> | 2009-08-13 09:27:13 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-08-20 09:20:56 -0400 |
commit | d9c54cd83e8c676e34497fa135786a626d5d1fc7 (patch) | |
tree | 9f0b4defe1bbc50d96cfedabf5d2b591de8eac53 | |
parent | 8780751330871033b13fc8fbb7eb0588baf4417d (diff) | |
download | freeipa-d9c54cd83e8c676e34497fa135786a626d5d1fc7.tar.gz freeipa-d9c54cd83e8c676e34497fa135786a626d5d1fc7.tar.xz freeipa-d9c54cd83e8c676e34497fa135786a626d5d1fc7.zip |
Clean up additional issues discovered with pylint and pychecker
-rw-r--r-- | ipa-client/ipaclient/ntpconf.py | 8 | ||||
-rwxr-xr-x | ipalib/aci.py | 2 | ||||
-rw-r--r-- | ipalib/errors.py | 16 | ||||
-rw-r--r-- | ipalib/plugins/group.py | 2 | ||||
-rw-r--r-- | ipapython/ipasslfile.py | 4 | ||||
-rw-r--r-- | ipapython/ipautil.py | 10 | ||||
-rw-r--r-- | ipapython/test/test_ipautil.py | 8 | ||||
-rw-r--r-- | ipaserver/install/dsinstance.py | 2 |
8 files changed, 30 insertions, 22 deletions
diff --git a/ipa-client/ipaclient/ntpconf.py b/ipa-client/ipaclient/ntpconf.py index e71a909b4..8ea4f6f32 100644 --- a/ipa-client/ipaclient/ntpconf.py +++ b/ipa-client/ipaclient/ntpconf.py @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -from ipapython.ipautil import * +from ipapython import ipautil import shutil ntp_conf = """# Permit time synchronization with our time source, but do not @@ -84,7 +84,7 @@ def config_ntp(server_fqdn, fstore = None): sub_dict = { } sub_dict["SERVER"] = server_fqdn - nc = template_str(ntp_conf, sub_dict) + nc = ipautil.template_str(ntp_conf, sub_dict) if fstore: fstore.backup_file("/etc/ntp.conf") @@ -105,7 +105,7 @@ def config_ntp(server_fqdn, fstore = None): fd.close() # Set the ntpd to start on boot - run(["/sbin/chkconfig", "ntpd", "on"]) + ipautil.run(["/sbin/chkconfig", "ntpd", "on"]) # Restart ntpd - run(["/sbin/service", "ntpd", "restart"]) + ipautil.run(["/sbin/service", "ntpd", "restart"]) diff --git a/ipalib/aci.py b/ipalib/aci.py index 926334c35..3c4b2acb6 100755 --- a/ipalib/aci.py +++ b/ipalib/aci.py @@ -268,7 +268,7 @@ def extract_group_cns(aci_list, client): try: group = client.get_entry_by_dn(dn, ['cn']) group_dn_to_cn[dn] = group.getValue('cn') - except ipaerror.IPAError, e: + except Exception: group_dn_to_cn[dn] = 'unknown' return group_dn_to_cn diff --git a/ipalib/errors.py b/ipalib/errors.py index caecdc382..2edefa746 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -1008,6 +1008,22 @@ class SameGroupError(ExecutionError): errno = 4017 format = _('A group may not be added as a member of itself') +class DefaultGroupError(ExecutionError): + """ + **4018** Raised when removing the default user group + + For example: + + >>> raise DefaultGroupError() + Traceback (most recent call last): + ... + DefaultGroupError: The default users group cannot be removed + + """ + + errno = 4018 + format = _('The default users group cannot be removed') + class BuiltinError(ExecutionError): """ **4100** Base class for builtin execution errors (*4100 - 4199*). diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py index 7acb40e49..4fe37ba44 100644 --- a/ipalib/plugins/group.py +++ b/ipalib/plugins/group.py @@ -117,7 +117,7 @@ class group_del(basegroup_del): 'cn', def_group_cn, self.filter_class, [''], self.container ) if dn == def_group_dn: - raise errors.DefaultGroup() + raise errors.DefaultGroupError() except errors.NotFound: pass diff --git a/ipapython/ipasslfile.py b/ipapython/ipasslfile.py index 5f4ea2a7b..2082e2683 100644 --- a/ipapython/ipasslfile.py +++ b/ipapython/ipasslfile.py @@ -17,7 +17,9 @@ import socket import errno -from httplib import UnimplementedFileMode +from httplib import UnimplementedFileMode, HTTPException + +error = HTTPException class SharedSocket: def __init__(self, sock): diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 2fa26fef8..240e0d872 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -600,16 +600,6 @@ def user_input_plain(prompt, default = None, allow_empty = True, allow_spaces = if ipavalidate.Plain(ret, not allow_empty, allow_spaces): return ret -def user_input_path(prompt, default = None, allow_empty = True): - if default != None and allow_empty: - prompt += " (enter \"none\" for empty)" - while True: - ret = user_input(prompt, default, allow_empty) - if allow_empty and ret.lower() == "none": - return "" - if ipavalidate.Path(ret, not allow_empty): - return ret - class AttributeValueCompleter: ''' Gets input from the user in the form "lhs operator rhs" diff --git a/ipapython/test/test_ipautil.py b/ipapython/test/test_ipautil.py index 7df8e99a9..98e8846c3 100644 --- a/ipapython/test/test_ipautil.py +++ b/ipapython/test/test_ipautil.py @@ -275,7 +275,7 @@ class TestTimeParser(unittest.TestCase): time = ipautil.parse_generalized_time(timestr) self.assertEqual(0, time.tzinfo.houroffset) self.assertEqual(0, time.tzinfo.minoffset) - offset = time.tzinfo.utcoffset(None) + offset = time.tzinfo.utcoffset() self.assertEqual(0, offset.seconds) timestr = "20051213141205+0500" @@ -283,7 +283,7 @@ class TestTimeParser(unittest.TestCase): time = ipautil.parse_generalized_time(timestr) self.assertEqual(5, time.tzinfo.houroffset) self.assertEqual(0, time.tzinfo.minoffset) - offset = time.tzinfo.utcoffset(None) + offset = time.tzinfo.utcoffset() self.assertEqual(5 * 60 * 60, offset.seconds) timestr = "20051213141205-0500" @@ -293,7 +293,7 @@ class TestTimeParser(unittest.TestCase): self.assertEqual(0, time.tzinfo.minoffset) # NOTE - the offset is always positive - it's minutes # _east_ of UTC - offset = time.tzinfo.utcoffset(None) + offset = time.tzinfo.utcoffset() self.assertEqual((24 - 5) * 60 * 60, offset.seconds) timestr = "20051213141205-0930" @@ -301,7 +301,7 @@ class TestTimeParser(unittest.TestCase): time = ipautil.parse_generalized_time(timestr) self.assertEqual(-9, time.tzinfo.houroffset) self.assertEqual(-30, time.tzinfo.minoffset) - offset = time.tzinfo.utcoffset(None) + offset = time.tzinfo.utcoffset() self.assertEqual(((24 - 9) * 60 * 60) - (30 * 60), offset.seconds) diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index f66959bc1..d7394e561 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -452,7 +452,7 @@ class DsInstance(service.Service): status = True try: certdb.load_cacert(cacert_fname) - except errors.CalledProcessError, e: + except ipautil.CalledProcessError, e: logging.critical("Error importing CA cert file named [%s]: %s" % (cacert_fname, str(e))) status = False |