@@ -139,14 +139,17 @@ def __init__(
139
139
/impala/_thrift_api.py#L152-L160
140
140
"""
141
141
if scheme in ("https" , "http" ) and thrift_transport is None :
142
+ port = port or 1000
142
143
ssl_context = None
143
144
if scheme == "https" :
144
145
ssl_context = create_default_context ()
145
146
ssl_context .check_hostname = check_hostname == "true"
146
147
ssl_cert = ssl_cert or "none"
147
148
ssl_context .verify_mode = ssl_cert_parameter_map .get (ssl_cert , CERT_NONE )
148
149
thrift_transport = thrift .transport .THttpClient .THttpClient (
149
- uri_or_host = f"{ scheme } ://{ host } :{ port } /cliservice/" ,
150
+ uri_or_host = "{scheme}://{host}:{port}/cliservice/" .format (
151
+ scheme = scheme , host = host , port = port
152
+ ),
150
153
ssl_context = ssl_context ,
151
154
)
152
155
@@ -259,26 +262,40 @@ def sasl_factory():
259
262
def _set_authorization_header (transport , username = None , password = None ):
260
263
username = username or "user"
261
264
password = password or "pass"
262
- auth_credentials = f"{ username } :{ password } " .encode ("UTF-8" )
265
+ auth_credentials = "{username}:{password}" .format (
266
+ username = username , password = password
267
+ ).encode ("UTF-8" )
263
268
auth_credentials_base64 = base64 .standard_b64encode (auth_credentials ).decode (
264
269
"UTF-8"
265
270
)
266
271
transport .setCustomHeaders (
267
- {"Authorization" : f"Basic { auth_credentials_base64 } " }
272
+ {
273
+ "Authorization" : "Basic {auth_credentials_base64}" .format (
274
+ auth_credentials_base64 = auth_credentials_base64
275
+ )
276
+ }
268
277
)
269
278
270
279
@staticmethod
271
- def _set_kerberos_header (transport , kerberos_service_name , host ) -> None :
280
+ def _set_kerberos_header (transport , kerberos_service_name , host ):
272
281
import kerberos
273
282
274
283
__ , krb_context = kerberos .authGSSClientInit (
275
- service = f"{ kerberos_service_name } @{ host } "
284
+ service = "{kerberos_service_name}@{host}" .format (
285
+ kerberos_service_name = kerberos_service_name , host = host
286
+ )
276
287
)
277
288
kerberos .authGSSClientClean (krb_context , "" )
278
289
kerberos .authGSSClientStep (krb_context , "" )
279
290
auth_header = kerberos .authGSSClientResponse (krb_context )
280
291
281
- transport .setCustomHeaders ({"Authorization" : f"Negotiate { auth_header } " })
292
+ transport .setCustomHeaders (
293
+ {
294
+ "Authorization" : "Negotiate {auth_header}" .format (
295
+ auth_header = auth_header
296
+ )
297
+ }
298
+ )
282
299
283
300
def __enter__ (self ):
284
301
"""Transport should already be opened by __init__"""
0 commit comments