From 64fa3dd4c3a03e7a677453c9150f84ffc4e91c7a Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 20 Apr 2009 13:58:26 -0400 Subject: Finish work replacing the errors module with errors2 Once this is committed we can start the process of renaming errors2 as errors. I thought that combinig this into one commit would be more difficult to review. --- ipalib/util.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'ipalib/util.py') diff --git a/ipalib/util.py b/ipalib/util.py index 3e47cc3a..54529b14 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -22,24 +22,21 @@ Various utility functions. """ import os -from os import path import imp import optparse import logging import time -from types import NoneType -from xmlrpclib import Binary import krbV import socket +from ipalib import errors2 def get_current_principal(): try: - return krbV.default_context().default_ccache().principal().name + return unicode(krbV.default_context().default_ccache().principal().name) except krbV.Krb5Error: - #TODO: do a kinit - print "Unable to get kerberos principal" - return None + #TODO: do a kinit? + raise errors2.CCacheError() def get_fqdn(): fqdn = "" @@ -57,16 +54,16 @@ def find_modules_in_dir(src_dir): """ Iterate through module names found in ``src_dir``. """ - if not (path.abspath(src_dir) == src_dir and path.isdir(src_dir)): + if not (os.path.abspath(src_dir) == src_dir and os.path.isdir(src_dir)): return - if path.islink(src_dir): + if os.path.islink(src_dir): return suffix = '.py' for name in sorted(os.listdir(src_dir)): if not name.endswith(suffix): continue - pyfile = path.join(src_dir, name) - if path.islink(pyfile) or not path.isfile(pyfile): + pyfile = os.path.join(src_dir, name) + if os.path.islink(pyfile) or not os.path.isfile(pyfile): continue module = name[:-len(suffix)] if module == '__init__': @@ -92,7 +89,7 @@ def import_plugins_subpackage(name): plugins = __import__(name + '.plugins').plugins except ImportError: return - src_dir = path.dirname(path.abspath(plugins.__file__)) + src_dir = os.path.dirname(os.path.abspath(plugins.__file__)) for name in find_modules_in_dir(src_dir): full_name = '%s.%s' % (plugins.__name__, name) __import__(full_name) -- cgit