本文整理汇总了Python中fastjsonrpc.client.Proxy.callRemote方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.callRemote方法的具体用法?Python Proxy.callRemote怎么用?Python Proxy.callRemote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fastjsonrpc.client.Proxy
的用法示例。
在下文中一共展示了Proxy.callRemote方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_timeout
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_timeout(self):
""" Google doesn't offer any services on our crazy ports """
addr = 'http://google.com:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_1, connectTimeout=0.1)
d = proxy.callRemote('sleep', 5)
def finished(result):
self.assertTrue(isinstance(result.value, TimeoutError))
d.addErrback(finished)
return d
示例2: test_anonymousError
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_anonymousError(self):
addr = 'http://localhost:%s' % self.portNumber
proxy = Proxy(addr, credentials=Anonymous())
d = proxy.callRemote('echo', '')
e = self.assertFailure(d, jsonrpc.JSONRPCError)
def finished(result):
self.assertEquals(result.strerror, 'Unauthorized')
self.assertEquals(result.errno, jsonrpc.INVALID_REQUEST)
e.addCallback(finished)
return d
示例3: test_anonymousLogin
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_anonymousLogin(self):
data = 'some random string'
addr = 'http://localhost:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_1, credentials=Anonymous())
d = proxy.callRemote('echo', data)
def finished(result):
self.assertEquals(result, data)
d.addCallback(finished)
return d
示例4: test_keywordsV2
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_keywordsV2(self):
data = 'some random string'
addr = 'http://localhost:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_2)
d = proxy.callRemote('echo', data=data)
def finished(result):
self.assertEquals(result, data)
d.addCallback(finished)
return d
示例5: test_loginWrongUser
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_loginWrongUser(self):
addr = 'http://localhost:%s' % self.portNumber
credentials = UsernamePassword('wrong user', 'password1')
proxy = Proxy(addr, credentials=credentials)
d = proxy.callRemote('echo', '')
e = self.assertFailure(d, jsonrpc.JSONRPCError)
def finished(result):
self.assertEquals(result.strerror, 'Unauthorized')
self.assertEquals(result.errno, jsonrpc.INVALID_REQUEST)
e.addCallback(finished)
return d
示例6: test_loginOk
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_loginOk(self):
data = 'some random string'
addr = 'http://localhost:%s' % self.portNumber
credentials = UsernamePassword('user', 'password')
proxy = Proxy(addr, credentials=credentials)
d = proxy.callRemote('echo', data)
def finished(result):
self.assertEquals(result, data)
d.addCallback(finished)
return d
示例7: test_callRemoteV1NoMethod
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_callRemoteV1NoMethod(self):
addr = 'http://localhost:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_1)
d = proxy.callRemote('nosuchmethod')
e = self.assertFailure(d, jsonrpc.JSONRPCError)
def finished(result):
self.assertEquals(result.strerror, 'Method nosuchmethod not found')
self.assertEquals(result.errno, jsonrpc.METHOD_NOT_FOUND)
self.assertEquals(result.version, jsonrpc.VERSION_1)
e.addCallback(finished)
return e
示例8: test_callRemoteV2InvalidParams
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_callRemoteV2InvalidParams(self):
addr = 'http://localhost:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_2)
d = proxy.callRemote('echo', 'abc', 'def')
e = self.assertFailure(d, jsonrpc.JSONRPCError)
def finished(result):
msg = 'jsonrpc_echo() takes exactly 2 arguments (3 given)'
self.assertEquals(result.strerror, msg)
self.assertEquals(result.errno, jsonrpc.INVALID_PARAMS)
self.assertEquals(result.version, unicode(jsonrpc.VERSION_2))
e.addCallback(finished)
return e
示例9: test_keywordsUnexpected
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_keywordsUnexpected(self):
data = 'some random string'
addr = 'http://localhost:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_1)
d = proxy.callRemote('echo', wrongname=data)
e = self.assertFailure(d, jsonrpc.JSONRPCError)
def finished(result):
msg = 'jsonrpc_echo() got an unexpected keyword argument ' + \
'\'wrongname\''
self.assertEquals(result.strerror, msg)
self.assertEquals(result.errno, jsonrpc.INVALID_PARAMS)
e.addCallback(finished)
return d
示例10: test_callRemote
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def test_callRemote(self):
"""
The test itself passes, but trial raises "Reactor was unclean" after
tearDown.. Might be related to
http://twistedmatrix.com/trac/ticket/5118
"""
data = 'some random string'
addr = 'https://localhost:%s' % self.portNumber
proxy = Proxy(addr, jsonrpc.VERSION_1,
contextFactory=WebClientContextFactory())
d = proxy.callRemote('echo', data)
def finished(result):
self.assertEquals(result, data)
d.addCallback(finished)
return d
示例11: printError
# 需要导入模块: from fastjsonrpc.client import Proxy [as 别名]
# 或者: from fastjsonrpc.client.Proxy import callRemote [as 别名]
def printError(error):
print 'error', error.value
def shutDown(data):
print "Shutting down reactor..."
reactor.stop()
address = 'http://localhost:8999'
credentials=UsernamePassword('user123', 'password456')
proxy = Proxy(address, credentials=credentials)
ds = []
d = proxy.callRemote('echo', ['ajajaj', 'bjbjbj'])
d.addCallbacks(printValue, printError)
ds.append(d)
d = proxy.callRemote('add', 14, 15)
d.addCallbacks(printValue, printError)
ds.append(d)
d = proxy.callRemote('mysql_first_user')
d.addCallbacks(printValue, printError)
ds.append(d)
d = proxy.callRemote('none')
d.addCallbacks(printValue, printError)
ds.append(d)