mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-22 14:23:19 -06:00
Clean up additional issues discovered with pylint and pychecker
This commit is contained in:
parent
8780751330
commit
d9c54cd83e
@ -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"])
|
||||
|
@ -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
|
||||
|
@ -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*).
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user