Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #176 from bolkedebruin/ISSUE-174
Browse files Browse the repository at this point in the history
Do conditional import higher up to make sure import stays in scope
  • Loading branch information
Wouter de Bie committed Oct 13, 2015
2 parents 047ce3d + f402b76 commit 639f90c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions snakebite/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
import struct
import uuid

_kerberos_available = False
try:
from snakebite.rpc_sasl import SaslRpcClient
from snakebite.kerberos import Kerberos
_kerberos_available = True
except ImportError:
pass

# Configure package logging
log = logger.getLogger(__name__)

Expand Down Expand Up @@ -174,11 +182,7 @@ def __init__(self, host, port, version, effective_user=None, use_sasl=False):
self.client_id = str(uuid.uuid4())
self.use_sasl = use_sasl
if self.use_sasl:
try:
# Only import if SASL is enabled
from snakebite.rpc_sasl import SaslRpcClient
from snakebite.kerberos import Kerberos
except ImportError:
if not _kerberos_available:
raise Exception("Kerberos libs not found. Please install snakebite using 'pip install snakebite[kerberos]'")

kerberos = Kerberos()
Expand Down

0 comments on commit 639f90c

Please sign in to comment.