Yijian
Yijian

Reputation: 11

How to get Class Variable Value from Python XML RPC Server

Hello I'm new to stackoverflow and to XMLRPC Server in Python:

I have a class with the following parameters and i registered the class as a instance in xmlrpc server: The Class:

class PacificPowerActiveLoad(PacificPowerLowerLevel):
"""Main Class."""
    def __init__(self, **kargs) -> None:
    """_summary."""
        super(PacificPowerActiveLoad, self,).__init__()
        # Parameter
        self.Ip =""
        self.Port = ""
        self.Mode = ""                  # 0: CC, 1: CR, 2: CP, 3: CE
        self.Form = 'Single'            # Single, Split, Three
        self.PhaseSelection = None
        self.Imax = ""
        self.CFSoll = ""

Server.py:

with SimpleXMLRPCServer(('localhost', 8000)) as server:
    server.register_instance(PacificPowerActiveLoad(Ip="localhost",Port="20001"), allow_dotted_names=True)
    server.register_multicall_functions()
    print('Serving XML-RPC on localhost port 8000')
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        print("\\nKeyboard interrupt received, exiting.")
        sys.exit(0)

Client.py:

import xmlrpc.client
Device_1 = xmlrpc.client.ServerProxy("http://localhost:8000")
print(Device_1.Ip)
print(Device_1.Port)

When i execute the Client.py. I would expect:

localhost
20001

but i get:

<xmlrpc.client._Method object at 0x00000296D6B73248>
<xmlrpc.client._Method object at 0x00000296D6B73248> 

Is there a good way to access the variables in the client.py and print the Value? Thank you for your help

Upvotes: 1

Views: 206

Answers (0)

Related Questions