def exampleActiveFds(): i = 0 c = xmlrpc.client('localhost', PORT, '/blah') c.nbExecute('echo', ['hello', 'world'], activeFdCall, i) c.work(0.0) while 1: (inFd, outFd, excFd) = c.activeFds() select.select(inFd, outFd, excFd) c.work(0.0)
def __talk__(self, command, *args): args = filter(lambda x, y=NONE: (x is not y), args) if not self.client: raise ClientError(ERR_CLOSE) try: return self.client.execute(command, args, timeout=self.timeout) except: self.client = xmlrpc.client(self.host, self.port) return self.client.execute(command, args, timeout=self.timeout)
def __init__(self, host, port, timeout=-1.0): self.host = host # host self.port = port # server port self.timeout = timeout # xmlrpc timeout self.client = xmlrpc.client(host, port) xmlrpc.setLogLevel(LOG_LEVEL) self.cmds = self.__talk__('getclient') if not self.cmds: raise ClientError('could not get command list')
def exampleFault(): try: c = xmlrpc.client('localhost', PORT, '/blah') print(c.execute('fault', ['Hello, World!'])) except xmlrpc.fault as f: sys.stderr.write('xmlrpc fault occurred:\n') sys.stderr.write('faultCode is: %s\n' % f.faultCode) sys.stderr.write('faultString is: %s\n' % f.faultString) traceback.print_exc() sys.exit(0) else: sys.stderr.write('xmlrpc fault test failed\n') sys.exit(1)
#!/usr/local/bin/python2.0 -O import sys import turbo_xmlrpc as xmlrpc if len(sys.argv) != 3: sys.stderr.write('usage: %s host port\n' % sys.argv[0]) sys.exit(0) host = sys.argv[1] port = int(sys.argv[2]) c = xmlrpc.client(host, port) xmlrpc.setLogLevel(0) print c.execute('kill', []) c = None
def exampleRequestExit(): c = xmlrpc.client('localhost', PORT, '/blah') print(c.execute('exit', []))
def examplePostpone(): c = xmlrpc.client('localhost', PORT, '/blah') print(c.execute('postpone', ['Hello, World!']))
def exampleClient(): c = xmlrpc.client('localhost', PORT, '/blah') print(c.execute('echo', ['Hello, World!']))
def exampleNbClient(): c = xmlrpc.client('localhost', PORT) r = c.nbExecute('echo', ['hello', 'world'], callback, 'Extra Args') c.work(10)
def exampleAuthClient(): c = xmlrpc.client('localhost', PORT, '/blah') print(c.execute('echo', ['Hello, World!'], 1.0, TEST_NAME, TEST_PASS))
def reconnect(self): self.client = xmlrpc.client(self.host, self.port)