Fix string/bytes problem && lint

pull/19456/head
Lidi Zheng 6 years ago
parent 7b82924066
commit ce41cde908
  1. 4
      examples/python/auth/_credentials.py
  2. 7
      examples/python/auth/customized_auth_client.py
  3. 7
      examples/python/auth/customized_auth_server.py

@ -22,8 +22,8 @@ import os
def _load_credential_from_file(filepath):
real_path = os.path.join(os.path.dirname(__file__), filepath)
with open(real_path, 'r') as f:
return bytes(f.read())
with open(real_path, 'rb') as f:
return f.read()
SERVER_CERTIFICATE = _load_credential_from_file('credentials/localhost.crt')

@ -20,7 +20,6 @@ from __future__ import print_function
import argparse
import contextlib
import logging
import os
import grpc
from examples import helloworld_pb2
@ -57,12 +56,6 @@ class AuthGateway(grpc.AuthMetadataPlugin):
callback(((_SIGNATURE_HEADER_KEY, signature),), None)
def _load_credential_from_file(filepath):
real_path = os.path.join(os.path.dirname(__file__), filepath)
with open(real_path, 'r') as f:
return f.read()
@contextlib.contextmanager
def create_client_channel(addr):
# Call credential object will be invoked for every single RPC

@ -20,7 +20,6 @@ from __future__ import print_function
import argparse
import contextlib
import logging
import os
import time
from concurrent import futures
@ -66,12 +65,6 @@ class SimpleGreeter(helloworld_pb2_grpc.GreeterServicer):
return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
def _load_credential_from_file(filepath):
real_path = os.path.join(os.path.dirname(__file__), filepath)
with open(real_path, 'r') as f:
return f.read()
@contextlib.contextmanager
def run_server(port):
# Bind interceptor to server

Loading…
Cancel
Save