~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

  • Committer: Jelmer Vernooij
  • Author(s): John Arbash Meinel, Jelmer Vernooij
  • Date: 2011-11-04 13:30:07 UTC
  • mto: This revision was merged to the branch mainline in revision 6239.
  • Revision ID: jelmer@samba.org-20111104133007-1zyejzwb5w5qs22l
Only attempt to import kerberos module once.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
    )
69
69
 
70
70
 
 
71
checked_kerberos = False
 
72
kerberos = None
 
73
 
 
74
 
71
75
class addinfourl(urllib2.addinfourl):
72
76
    '''Replacement addinfourl class compatible with python-2.7's xmlrpclib
73
77
 
1319
1323
 
1320
1324
    def _auth_match_kerberos(self, auth):
1321
1325
        """Try to create a GSSAPI response for authenticating against a host."""
1322
 
        try:
1323
 
            import kerberos
1324
 
        except ImportError:
 
1326
        global kerberos, checked_kerberos
 
1327
        if kerberos is None and not checked_kerberos:
 
1328
            try:
 
1329
                import kerberos
 
1330
            except ImportError:
 
1331
                kerberos = None
 
1332
            checked_kerberos = True
 
1333
        if kerberos is None:
1325
1334
            return None
1326
1335
        ret, vc = kerberos.authGSSClientInit("HTTP@%(host)s" % auth)
1327
1336
        if ret < 1: