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


Python client.ServerProxy方法代码示例

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


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

示例1: test_distribute

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def test_distribute(self):
        real_urlopen = urllib.urlopen
        real_server_proxy = xmlrpclib.ServerProxy
        try:
            xmlrpclib.ServerProxy = ProxyStub(
                "distributedata.py", xmlrpclib.ServerProxy, False
            )
            urllib.urlopen = urlopenstub
            data = pypidata.get_data("distribute")
            rating = rate(data)

            self.assertEqual(
                rating,
                (
                    9,
                    [
                        "The classifiers should specify what minor versions of Python "
                        "you support as well as what major version.",
                        "You should have three or more owners of the project on PyPI.",
                    ],
                ),
            )
        finally:
            xmlrpclib.ServerProxy = real_server_proxy
            urllib.urlopen = real_urlopen 
开发者ID:regebro,项目名称:pyroma,代码行数:27,代码来源:tests.py

示例2: search

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def search(self, query: Iterable[str]) -> List[Dict[str, str]]:
        fields = self._parse_query(query=query)
        logger.debug('search on PyPI', extra=dict(query=fields))
        invalid_fields = set(fields) - _fields
        if invalid_fields:
            raise InvalidFieldsError(fields=invalid_fields)

        with ServerProxy('https://pypi.org/pypi') as client:
            response = client.search(fields, 'and')

        results = []
        for info in response:
            results.append(dict(
                name=info['name'],
                version=info['version'],
                description=info['summary'],
                url='https://pypi.org/project/{}/'.format(info['name']),
            ))
        return results 
开发者ID:dephell,项目名称:dephell,代码行数:21,代码来源:_api.py

示例3: attach_volume

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def attach_volume(self, vm, disk_size, disk_device, disk_fstype, session_id):
        server = ServerProxy(self.server_url, allow_none=True)

        disk_temp = '''
            DISK = [
                TYPE = fs ,
                FORMAT = %s,
                SIZE = %d,
                TARGET = %s,
                SAVE = no
                ]
        ''' % (disk_fstype, disk_size, disk_device)

        success, res_info = server.one.vm.attach(session_id, int(vm.id), disk_temp, False)[0:2]
        if success:
            return (True, "")
        else:
            return (False, res_info) 
开发者ID:grycap,项目名称:im,代码行数:20,代码来源:OpenNebula.py

示例4: delete_image

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def delete_image(self, image_url, auth_data):
        server = ServerProxy(self.server_url, allow_none=True)

        session_id = self.getSessionID(auth_data)
        if session_id is None:
            return (False, "Incorrect auth data, username and password must be specified for OpenNebula provider.")

        image_id = self.get_image_id(image_url, session_id)
        if image_id is None:
            return (False, "Incorrect image name or id specified.")

        # Wait the image to be READY (not USED)
        success, msg = self.wait_image(image_id, auth_data)
        if not success:
            self.logger.warn("Error waiting image to be READY: " + msg)

        success, res_info = server.one.image.delete(session_id, image_id)[0:2]
        if success:
            return (True, "")
        else:
            return (False, res_info) 
开发者ID:grycap,项目名称:im,代码行数:23,代码来源:OpenNebula.py

示例5: get_image_id

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def get_image_id(self, image_url, session_id):
        url = urlparse(image_url)
        image_id = url[2][1:]
        if image_id.isdigit():
            return int(image_id)
        else:
            # We have to find the ID of the image name
            server = ServerProxy(self.server_url, allow_none=True)
            success, res_info = server.one.imagepool.info(session_id, -2, -1, -1)[0:2]
            if success:
                pool_info = IMAGE_POOL(res_info)
            else:
                self.logger.error("Error in the function one.imagepool.info: " + res_info)
                return None

            for image in pool_info.IMAGE:
                if image.NAME == image_id:
                    return image.ID

            return None 
开发者ID:grycap,项目名称:im,代码行数:22,代码来源:OpenNebula.py

示例6: update

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def update(self, instance, validated_data):
        """Update a Provider instance from validated data."""
        billing_source = validated_data.get("billing_source")
        authentication = validated_data.get("authentication")

        try:
            with ServerProxy(SOURCES_CLIENT_BASE_URL) as sources_client:
                if billing_source:
                    billing_source = self._update_billing_source(instance, billing_source)
                    sources_client.update_billing_source(instance.source_id, billing_source)
                if authentication:
                    authentication = self._update_authentication(instance, authentication)
                    sources_client.update_authentication(instance.source_id, authentication)
        except Fault as error:
            LOG.error(f"Sources update error: {error}")
            raise SourcesStorageError(str(error))
        except (ConnectionRefusedError, gaierror, ProtocolError) as error:
            LOG.error(f"Sources update dependency error: {error}")
            raise SourcesDependencyError(f"Sources-client: {error}")
        return get_source_instance(instance.source_id) 
开发者ID:project-koku,项目名称:koku,代码行数:22,代码来源:serializers.py

示例7: Open

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def Open(self, hostname, port):
    """Opens a RPC communication channel to the server.

    Args:
      hostname (str): hostname or IP address to connect to for requests.
      port (int): port to connect to for requests.

    Returns:
      bool: True if the communication channel was established.
    """
    server_url = 'http://{0:s}:{1:d}'.format(hostname, port)

    try:
      self._xmlrpc_proxy = xmlrpclib.ServerProxy(
          server_url, allow_none=True)
    except SocketServer.socket.error as exception:
      logger.warning((
          'Unable to connect to RPC server on {0:s}:{1:d} with error: '
          '{2!s}').format(hostname, port, exception))
      return False

    return True 
开发者ID:log2timeline,项目名称:plaso,代码行数:24,代码来源:plaso_xmlrpc.py

示例8: __get_state_str_raw

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def __get_state_str_raw(self):
        if self.device.humanoid is not None:
            import json
            from xmlrpc.client import ServerProxy
            proxy = ServerProxy("http://%s/" % self.device.humanoid)
            return proxy.render_view_tree(json.dumps({
                "view_tree": self.view_tree,
                "screen_res": [self.device.display_info["width"],
                               self.device.display_info["height"]]
            }))
        else:
            view_signatures = set()
            for view in self.views:
                view_signature = DeviceState.__get_view_signature(view)
                if view_signature:
                    view_signatures.add(view_signature)
            return "%s{%s}" % (self.foreground_activity, ",".join(sorted(view_signatures))) 
开发者ID:honeynet,项目名称:droidbot,代码行数:19,代码来源:device_state.py

示例9: __get_content_free_state_str

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def __get_content_free_state_str(self):
        if self.device.humanoid is not None:
            import json
            from xmlrpc.client import ServerProxy
            proxy = ServerProxy("http://%s/" % self.device.humanoid)
            state_str = proxy.render_content_free_view_tree(json.dumps({
                "view_tree": self.view_tree,
                "screen_res": [self.device.display_info["width"],
                               self.device.display_info["height"]]
            }))
        else:
            view_signatures = set()
            for view in self.views:
                view_signature = DeviceState.__get_content_free_view_signature(view)
                if view_signature:
                    view_signatures.add(view_signature)
            state_str = "%s{%s}" % (self.foreground_activity, ",".join(sorted(view_signatures)))
        import hashlib
        return hashlib.md5(state_str.encode('utf-8')).hexdigest() 
开发者ID:honeynet,项目名称:droidbot,代码行数:21,代码来源:device_state.py

示例10: test_multicall

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def test_multicall(self):
        try:
            p = xmlrpclib.ServerProxy(URL)
            multicall = xmlrpclib.MultiCall(p)
            multicall.add(2,3)
            multicall.pow(6,8)
            multicall.div(127,42)
            add_result, pow_result, div_result = multicall()
            self.assertEqual(add_result, 2+3)
            self.assertEqual(pow_result, 6**8)
            self.assertEqual(div_result, 127//42)
        except (xmlrpclib.ProtocolError, OSError) as e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_xmlrpc.py

示例11: test_non_existing_multicall

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def test_non_existing_multicall(self):
        try:
            p = xmlrpclib.ServerProxy(URL)
            multicall = xmlrpclib.MultiCall(p)
            multicall.this_is_not_exists()
            result = multicall()

            # result.results contains;
            # [{'faultCode': 1, 'faultString': '<class \'exceptions.Exception\'>:'
            #   'method "this_is_not_exists" is not supported'>}]

            self.assertEqual(result.results[0]['faultCode'], 1)
            self.assertEqual(result.results[0]['faultString'],
                '<class \'Exception\'>:method "this_is_not_exists" '
                'is not supported')
        except (xmlrpclib.ProtocolError, OSError) as e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_xmlrpc.py

示例12: test_close

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def test_close(self):
        p = xmlrpclib.ServerProxy(URL)
        #do some requests with close.
        self.assertEqual(p.pow(6,8), 6**8)
        self.assertEqual(p.pow(6,8), 6**8)
        self.assertEqual(p.pow(6,8), 6**8)
        p("close")() #this should trigger a new keep-alive request
        self.assertEqual(p.pow(6,8), 6**8)
        self.assertEqual(p.pow(6,8), 6**8)
        self.assertEqual(p.pow(6,8), 6**8)
        p("close")()

        #they should have all been two request handlers, each having logged at least
        #two complete requests
        self.assertEqual(len(self.RequestHandler.myRequests), 2)
        self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
        self.assertGreaterEqual(len(self.RequestHandler.myRequests[-2]), 2) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_xmlrpc.py

示例13: test_basic

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def test_basic(self):
        # check that flag is false by default
        flagval = xmlrpc.server.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, OSError) as e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_xmlrpc.py

示例14: test_fail_with_info

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def test_fail_with_info(self):
        # use the broken message class
        xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        # Check that errors in the server send back exception/traceback
        # info when flag is set
        xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, OSError) as e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # We should get error info in the response
                expected_err = "invalid literal for int() with base 10: 'I am broken'"
                self.assertEqual(e.headers.get("X-exception"), expected_err)
                self.assertTrue(e.headers.get("X-traceback") is not None)
        else:
            self.fail('ProtocolError not raised') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_xmlrpc.py

示例15: find_packages

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ServerProxy [as 别名]
def find_packages(self, name, constraint=None):
        packages = []

        if constraint is not None:
            version_parser = VersionParser()
            constraint = version_parser.parse_constraints(constraint)

        with ServerProxy(self._url) as client:
            versions = client.package_releases(name, True)

        if constraint:
            versions = constraint.select([Version.coerce(v) for v in versions])

        for version in versions:
            try:
                packages.append(Package(name, version))
            except ValueError:
                continue

        return packages 
开发者ID:sdispater,项目名称:poet,代码行数:22,代码来源:pypi_repository.py


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