当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.get方法代码示例

本文整理汇总了Python中xmlrpc.client.ServerProxy.get方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.get方法的具体用法?Python ServerProxy.get怎么用?Python ServerProxy.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpc.client.ServerProxy的用法示例。


在下文中一共展示了ServerProxy.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: VerifyCertSafeTransport

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import get [as 别名]
class VerifyCertSafeTransport(SafeTransport):

    def __init__(self, cafile, certfile=None, keyfile=None):
        super().__init__()
        self._ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        self._ssl_context.load_verify_locations(cafile)
        if certfile:
            self._ssl_context.load_cert_chain(certfile, keyfile)
        self._ssl_context.verify_mode = ssl.CERT_REQUIRED

    def make_connection(self, host):
        s = super().make_connection((host, {'context': self._ssl_context}))
        return s


# Create the client proxy
s = ServerProxy('https://localhost:15000',
                transport=VerifyCertSafeTransport('server_cert.pem',
                                                  'client_cert.pem',
                                                  'client_key.pem'),
                allow_none=True)


s.set('foo', 'bar')
s.set('spam', [1, 2, 3])
print(s.keys())
print(s.get('foo'))
print(s.get('spam'))
s.delete('spam')
print(s.exists('spam'))
开发者ID:xuyan0,项目名称:pycookbook,代码行数:32,代码来源:ssl_xmlrpc_client.py

示例2: ServerProxy

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import get [as 别名]
__author__ = 'PyBeaner'

from xmlrpc.client import ServerProxy

s = ServerProxy("http://localhost:20000",allow_none=True)
s.set("foo","bar")
print(s.get("foo"))

print(s.keys())
print(s.exists("foo"))
if s.exists("foo"):
    s.delete("foo")
开发者ID:PyBeaner,项目名称:PythonCookbook,代码行数:14,代码来源:client.py

示例3: main

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import get [as 别名]
def main():
    # before running test, please ensure that modules
    # are running on the following addresses:
    coord_name = "http://localhost:10000"
    srv1_name = "http://localhost:10001"
    srv2_name = "http://localhost:10002"

    coordinator = ServerProxy(coord_name)
    server1 = ServerProxy(srv1_name)
    server2 = ServerProxy(srv2_name)
    longDelay = 10

    try:
        # first master
        for i in range(longDelay):
            coordinator.tick()
            server1.tick()
        test(coordinator.master() == srv1_name, "first master")
        server1.put("a", "aaa")
        test(server1.get("a") == "aaa")

        # first backup
        for i in range(longDelay):
            coordinator.tick()
            server1.tick()
            server2.tick()
        test(coordinator.master() == srv1_name, "first backup")
        server1.put("b", "bbb")
        test(server1.get("b") == "bbb", "first backup")

        # master fails
        for i in range(longDelay):
            coordinator.tick()
            server2.tick()
        test(coordinator.master() == srv2_name, "master fails")
        test(server2.get("a") == "aaa", "master fails")
        test(server2.get("b") == "bbb", "master fails")

        # ex-master restarts
        for i in range(longDelay):
            coordinator.tick()
            server1.tick()
            server2.tick()
        test(coordinator.master() == srv2_name, "ex-master restarts")

        # oh no! network partition
        # client sees server2, but coordinator does not
        for i in range(longDelay):
            coordinator.tick()
            server1.tick()
        test(coordinator.master() == srv1_name, "network partition")
        test(server1.get("a") == "aaa", "network partition")
        test(server1.get("b") == "bbb", "network partition")
        try:
            server2.put("c", "ccc")
            raise TestFailedException("Must throw!")
        except xmlrpc.client.Fault:
            pass # ok

    except TestFailedException as e:
        sys.stderr.write("Test failed: %s\n" % e)
开发者ID:vitaly-emelianov,项目名称:distribsys2015,代码行数:63,代码来源:test_server.py

示例4: __exit__

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import get [as 别名]
	
	def __exit__(self, type, value, traceback):
		"""
		Remove the working directory completely.  Ignore any warnings about
		it still containing files.
		"""
		rmtree(self.work_dir, True)
		log("Removed working directory.")

if len(sys.argv) != 3:
	raise ValueError("Usage:  %s %s <http hostname> <master hostname>" % (sys.executable, sys.argv[0]))

http_hostname = sys.argv[1]
master_hostname = sys.argv[2]

master = ServerProxy("http://%s" % master_hostname)

with Slave(http_hostname) as s:
	while True:
		id = master.get()
			
		if not id:
			log("No more work.  Terminating.")
			break

		try:
			s.test(id)
		except:
			log("*** ERROR ***:  Something went wrong with the test.")

开发者ID:baongoc124,项目名称:distributed-mutation-testing,代码行数:31,代码来源:slave.py

示例5: KeyValueServer

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import get [as 别名]
        self._serv.serve_forever()

#Example
if __name__ == '__main__':
    kvserv = KeyValueServer( ('', 15000))
    kvserv.serve_forever()

# Test Client code
from xmlrpc.client import ServerProxy

s = ServerProxy('http://localhost:15000', allow_none = True)
s.set( 'foo', 'bar')
s.set( 'spam', [1, 2, 3])
s.keys()
#['foo', 'spam'] 
s.get('foo')
#'bar'
s.get('spam')
#[1, 2, 3]
s.delete('spam')
s.exists('spam')
#False

# Ex 11-7

from multiprocessing.connection import Listener
import traceback

def echo_client(conn):
    try:
        while True:
开发者ID:dodo99,项目名称:PythonCookbookExamples,代码行数:33,代码来源:chapter_11.py


注:本文中的xmlrpc.client.ServerProxy.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。