Avoid failing at import time if krbV module is missing

Several parts of Koji already handled this absence gracefully. This change
extends that behavior to all places where krbV is imported.
This commit is contained in:
Mike McLean 2017-11-17 11:20:00 +08:00
parent dad74a3a9e
commit 91b306e108
5 changed files with 15 additions and 9 deletions

View file

@ -9,7 +9,7 @@
try:
import krbV
except ImportError: # pragma: no cover
pass
krbV = None
import koji
from koji.util import LazyDict, LazyValue
import koji.policy
@ -345,7 +345,7 @@ def ensure_connection(session):
warn(_("WARNING: The server is at API version %d and the client is at %d" % (ret, koji.API_VERSION)))
def has_krb_creds():
if 'krbV' not in sys.modules:
if krbV is None or 'krbV' not in sys.modules:
return False
try:
ctx = krbV.default_context()

View file

@ -25,7 +25,7 @@
try:
import krbV
except ImportError: # pragma: no cover
pass
krbV = None
import koji
import ConfigParser
import fnmatch
@ -320,7 +320,7 @@ def activate_session(session):
elif options.user:
#authenticate using user/password
session.login()
elif 'krbV' in sys.modules:
elif krbV and 'krbV' in sys.modules:
try:
if options.keytab and options.principal:
session.krb_login(principal=options.principal, keytab=options.keytab, proxyuser=options.runas)