from __future__ import with_statement
from sikuli.Sikuli import *
import os
import unittest
import this
import xmlrpclib
import SimpleXMLRPCServer, SocketServer, threading
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
pass
class ABC(object):
def A(self):
...........
def B(self):
...........
def C(self):
...........
class XYZ(unittest.TestCase,ABC):
def setUp(self):
print "Inside setup"
pass
def tearDown(self):
print "Inside tearDown"
pass
def test_1(self):
self.A()
self.B()
self.C()
def D(self):
print "Inside D"
return True
suite = unittest.TestLoader().loadTestsFromTestCase(XYZ)
class ServerThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.server = SimpleThreadedXMLRPCServer(("x.x.x.1", 8000))
#self.server.register_instance() #How to Register an instance of XYZ here.
def run(self):
self.server.serve_forever()
server = ServerThread()
server.start()
所以我的问题是如何在XYZ
这里注册一个实例。在上面的注释行中,以便可以从 XMLRPC 客户端调用它,例如:
client = xmlrpclib.ServerProxy("http://x.x.x.2:8000")
handraise = client.D() #Or any other possible way
我知道它可以使用,register_function(D)
但我希望整个班级XYZ
都可以使用register_instance()
.