def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.GreeterStub(channel)
        response = stub.Add(calculator_pb2.AddRequest(num1=2, num2=5))
    print(response.num3)
Esempio n. 2
0
def run():
    print("Input numbers 'x' and 'y' to calculate addition:")
    x = float(input("x: "))
    y = float(input("y: "))
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        response = stub.Add(calculator_pb2.AddRequest(x=x, y=y))
    print("Addition result: " + str(response.result))
Esempio n. 3
0
def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.AdditionStub(channel)
        response = stub.PerformAddition(calculator_pb2.AddRequest(nbr1=4, nbr2=5))
    print(response.message)
Esempio n. 4
0
def start():
    channel = grpc.insecure_channel('localhost:50051')
    stub = calculator_pb2_grpc.AdditionStub(channel)
    integer1 = 34
    integer2 = 45
    response = stub.add(
        calculator_pb2.AddRequest(number1=integer1, number2=integer2))
    print("The addition of " + str(integer1) + " and " + str(integer2) +
          " is " + str(response.message))
def run():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        print("This program will call add(x,y) as remote procedure")
        x = input("x=")
        y = input("y=")
        print("Calculator client sending x={} and y={}".format(x,y))
        response = stub.add(calculator_pb2.AddRequest(x=x, y=y))
        print("Calculator client received: " + str(response.result))
Esempio n. 6
0
def run():

    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        value1 = input("Enter value 1:")
        value2 = input("Enter value 2:")
        response = stub.addition(
            calculator_pb2.AddRequest(val1=int(value1), val2=int(value2)))
    print("Sum of the two numbers is " + str(response.result))
def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
    #channel: grpc.insecure_channel('localhost:50051')
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        response = stub.Add(calculator_pb2.AddRequest(x=4,y=2))
    print("Addition request received and sum: {}".format(response.z))
Esempio n. 8
0
def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        num1 = int(input("Enter first number: "))
        num2 = int(input("Enter second number: "))
        response = stub.Add(calculator_pb2.AddRequest(a=num1, b=num2))
    print("Sum: %d" % response.sum)
Esempio n. 9
0
def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.GreeterStub(channel)
        x = 3.0
        y = 2.0
        response = stub.Add(calculator_pb2.AddRequest(x=x, y=y))
        print('Adder Request is done with x= %.2f and y = %.2f' % (x, y))
        print("Adder client received: %.2f" % response.result)
Esempio n. 10
0
def run():
	# NOTE(gRPC Python Team): .close() is possible on a channel and should be
	# used in circumstances in which the with statement does not fit the needs
	# of the code.
	file = open("output.txt",'w')

	with grpc.insecure_channel('localhost:50051') as channel:
		stub = calculator_pb2_grpc.additionStub(channel)

		response = stub.AddStuff(calculator_pb2.AddRequest(a = 1, b = 2))
		print("Sum retunred to client: " + str(response.message))
		file.write("Sum retunred to client: " + str(response.message)+" \n")

	file.close()
def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.AdditionStub(channel)
        #Accept two numbers from user
        input1 = input("Enter number one for addition:\t")
        input2 = input("Enter number two for addition:\t")
        #Sends the 2 numbers as request parameters
        response = stub.Addition(
            calculator_pb2.AddRequest(num1=int(input1), num2=int(input2)))
        #Response should be str
        print("Addition of two number is:\t" + str(response.result))
Esempio n. 12
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = calculator_pb2_grpc.CalculatorStub(channel)
    response = stub.Add(calculator_pb2.AddRequest(n1=1, n2=2))
    print("1 + 2 = %d" % response.message)
def run():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        response = stub.add(calculator_pb2.AddRequest(a=4, b=8))
        print(f"The sum of 4 and 8 is {response.c}")
Esempio n. 14
0
def run():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = calculator_pb2_grpc.CalculatorStub(channel)
        response = stub.Add(calculator_pb2.AddRequest(x=n1, y=n2))
    print("Calculation result: " + str(response.result))
Esempio n. 15
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = calculator_pb2_grpc.GreeterStub(channel)
    response = stub.Add(calculator_pb2.AddRequest(n1=50, n2=230))
    print("the sum of two numbers is :", response.n1)