Last active
June 10, 2018 16:13
-
-
Save b1tg/7e94acbf1a996f3e9a46dae65ad55413 to your computer and use it in GitHub Desktop.
[Python RPC上报数据] https://www.jianshu.com/p/40af791a7b1e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xmlrpclib | |
import random | |
import schedule | |
address="127.0.0.1" | |
proxy = xmlrpclib.ServerProxy("http://"+ address +":8000/", allow_none = True) | |
multicall = xmlrpclib.MultiCall(proxy) | |
def tt(): | |
value={ | |
'device':'light', | |
'status':'0' | |
} | |
multicall.test(random.random(), value) | |
multicall.config() | |
result = multicall() | |
print(result[0], result[1]) | |
schedule.every(5).seconds.do(tt) | |
while 1: | |
schedule.run_pending() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from SimpleXMLRPCServer import SimpleXMLRPCServer | |
def test(a,b): | |
print('got:%s, %s' %(a,b)) | |
return "sent" | |
def config(): | |
return { | |
'a':0, | |
'b':1 | |
} | |
server = SimpleXMLRPCServer(('127.0.0.1', 8000), allow_none=True) | |
server.register_multicall_functions() | |
server.register_function(test,'test') | |
server.register_function(config,'config') | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment