本文整理汇总了Python中pyamf.remoting.client.RemotingService.setCredentials方法的典型用法代码示例。如果您正苦于以下问题:Python RemotingService.setCredentials方法的具体用法?Python RemotingService.setCredentials怎么用?Python RemotingService.setCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyamf.remoting.client.RemotingService
的用法示例。
在下文中一共展示了RemotingService.setCredentials方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OptionParser
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import setCredentials [as 别名]
import logging
from optparse import OptionParser
from pyamf.remoting.client import RemotingService
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
)
parser = OptionParser()
parser.add_option("-p", "--port", default=8000,
dest="port", help="port number [default: %default]")
parser.add_option("--host", default="localhost",
dest="host", help="host address [default: %default]")
(options, args) = parser.parse_args()
url = 'http://%s:%d' % (options.host, int(options.port))
client = RemotingService(url, logger=logging)
client.setCredentials('jane', 'doe')
calc_service = client.getService('calc')
print calc_service.sum(85, 115) # should print 200.0
client.setCredentials('abc', 'def')
print calc_service.sum(85, 115).description # should print Authentication Failed
示例2: RemotingService
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import setCredentials [as 别名]
import time
from pyamf.remoting.client import RemotingService
client = RemotingService('http://127.0.0.1:18801')
client.setCredentials('controller','1234')
service = client.getService('controller')
for i in range(1):
print service.is_alive()
time.sleep(2)