def runUserSubmit(uid, hk): with grpc.insecure_channel('0.0.0.0:50051') as channel: stub = flagging_pb2_grpc.PhotoFlaggingStub(channel) response = stub.UserSubmit( flagging_pb2.UserSubmitRequest(userId=uid, hashKey=hk)) result = {'rejected': response.rejected, 'existed': response.existed} return result
def runAdminRequest(uid): with grpc.insecure_channel('0.0.0.0:50051') as channel: stub = flagging_pb2_grpc.PhotoFlaggingStub(channel) response = stub.AdminRequest( flagging_pb2.AdminRequestRequest(userId=uid)) result = {} ##create the output dictionary hash is the key, flag is the value for h, f in zip(response.hashKeyList, response.flaggedList): result[h] = f return result
def runUserRequest(uid): with grpc.insecure_channel('0.0.0.0:50051') as channel: stub = flagging_pb2_grpc.PhotoFlaggingStub(channel) response = stub.UserRequest( flagging_pb2.UserRequestRequest(userId=uid)) return response.unflaggedHash