#NEWLINE# def hdfs_connect( host = 'localhost' , port = 50070 , protocol = 'webhdfs' , use_https = 'default' , auth_mechanism = 'NOSASL' , verify = True , **kwds ) : #NEWLINE# #INDENT# "\n    Connect to HDFS\n\n    Parameters\n    ----------\n    host : string, Host name of the HDFS NameNode\n    port : int, NameNode's WebHDFS port (default 50070)\n    protocol : {'webhdfs'}\n    use_https : boolean, default 'default'\n        Connect to WebHDFS with HTTPS, otherwise plain HTTP. For secure\n        authentication, the default for this is True, otherwise False\n    auth_mechanism : string, Set to NOSASL or PLAIN for non-secure clusters.\n        Set to GSSAPI or LDAP for Kerberos-secured clusters.\n    verify : boolean, Set to False to turn off verifying SSL certificates.\n        (default True)\n\n    Other keywords are forwarded to hdfs library classes\n\n    Returns\n    -------\n    client : WebHDFS\n    " #NEWLINE# import requests #NEWLINE# session = kwds . setdefault ( 'session' , requests . Session ( ) ) #NEWLINE# session . verify = verify #NEWLINE# if ( auth_mechanism in [ 'GSSAPI' , 'LDAP' ] ) : #NEWLINE# #INDENT# if ( use_https == 'default' ) : #NEWLINE# #INDENT# prefix = 'https' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# prefix = ( 'https' if use_https else 'http' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# import requests_kerberos #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise IbisError ( 'Unable to import requests-kerberos, which is required for Kerberos HDFS support. Install it by executing `pip install requests-kerberos` or `pip install hdfs[kerberos]`.' ) #NEWLINE# #UNINDENT# from hdfs.ext.kerberos import KerberosClient #NEWLINE# url = '{0}://{1}:{2}' . format ( prefix , host , port ) #NEWLINE# kwds . setdefault ( 'mutual_auth' , 'OPTIONAL' ) #NEWLINE# hdfs_client = KerberosClient ( url , ** kwds ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( use_https == 'default' ) : #NEWLINE# #INDENT# prefix = 'http' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# prefix = ( 'https' if use_https else 'http' ) #NEWLINE# #UNINDENT# from hdfs.client import InsecureClient #NEWLINE# url = '{0}://{1}:{2}' . format ( prefix , host , port ) #NEWLINE# hdfs_client = InsecureClient ( url , ** kwds ) #NEWLINE# #UNINDENT# return WebHDFS ( hdfs_client )