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


Python client.Fault方法代码示例

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


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

示例1: execute

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def execute(self, group, command, *args, **kwargs):
        """Executes the given command with MySQL protocol

        Executes the given command with the given parameters.

        Returns an iterator to navigate to navigate through the result set
        returned by Fabric
        """
        params = self.create_params(*args, **kwargs)
        cmd = "CALL {0}.{1}({2})".format(group, command, params)

        fab_set = None
        try:
            data = self._execute_cmd(cmd)
            fab_set = FabricMySQLSet(data)
        except (Fault, socket.error, InterfaceError) as exc:
            msg = "Executing {group}.{command} failed: {error}".format(
                group=group, command=command, error=str(exc))
            raise InterfaceError(msg)

        return fab_set 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:23,代码来源:connection.py

示例2: report_failure

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def report_failure(self, server_uuid, errno):
        """Report failure to Fabric

        This method sets the status of a MySQL server identified by
        server_uuid.
        """
        if not self._report_errors:
            return

        errno = int(errno)
        current_host = socket.getfqdn()

        if errno in REPORT_ERRORS or errno in REPORT_ERRORS_EXTRA:
            _LOGGER.debug("Reporting error %d of server %s", errno,
                          server_uuid)
            inst = self.get_instance()
            try:
                data = inst.execute('threat', 'report_failure',
                                    server_uuid, current_host, errno)
                FabricResponse(data)
            except (Fault, socket.error) as exc:
                _LOGGER.debug("Failed reporting server to Fabric (%s)",
                              str(exc))
                # Not requiring further action 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:26,代码来源:connection.py

示例3: is_connected

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def is_connected(self):
        """Check whether connection with Fabric is valid

        Return True if we can still interact with the Fabric server; False
        if Not.

        Returns True or False.
        """
        try:
            self._proxy._some_nonexisting_method()  # pylint: disable=W0212
        except Fault:
            return True
        except (TypeError, AttributeError):
            return False
        else:
            return False 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:18,代码来源:connection.py

示例4: send

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def send(self, command, *args, **kwargs):
        """Generic method for executing an XML-RPC *command*. *args* and
        *kwargs* are the arguments and parameters needed by the command.
        """
        args = list(args)
        if kwargs:
            args.append(kwargs)

        method = self.proxy
        for elt in command.split('.'):
            method = getattr(method, elt)

        try:
            return method(*args)
        except Fault as err:
            if err.faultCode == 121:
                return {}
            elif err.faultCode == 321:
                return []
            raise DokuWikiError(err)
        except ExpatError as err:
            if str(err) != ERR:
                raise DokuWikiError(err) 
开发者ID:fmenabe,项目名称:python-dokuwiki,代码行数:25,代码来源:dokuwiki.py

示例5: update

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [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

示例6: CallFunction

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def CallFunction(self):
    """Calls the function via RPC."""
    if self._xmlrpc_proxy is None:
      return None

    rpc_call = getattr(self._xmlrpc_proxy, self._RPC_FUNCTION_NAME, None)
    if rpc_call is None:
      return None

    try:
      return rpc_call()  # pylint: disable=not-callable
    except (
        expat.ExpatError, SocketServer.socket.error,
        xmlrpclib.Fault) as exception:
      logger.warning('Unable to make RPC call with error: {0!s}'.format(
          exception))
      return None 
开发者ID:log2timeline,项目名称:plaso,代码行数:19,代码来源:plaso_xmlrpc.py

示例7: _marshaled_dispatch

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
        try:
            response = self.dispatchers[path]._marshaled_dispatch(
               data, dispatch_method, path)
        except:
            # report low level exception back to server
            # (each dispatcher should have handled their own
            # exceptions)
            exc_type, exc_value = sys.exc_info()[:2]
            try:
                response = dumps(
                    Fault(1, "%s:%s" % (exc_type, exc_value)),
                    encoding=self.encoding, allow_none=self.allow_none)
                response = response.encode(self.encoding, 'xmlcharrefreplace')
            finally:
                # Break reference cycle
                exc_type = exc_value = None
        return response 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:20,代码来源:server.py

示例8: getAttachments

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def getAttachments(self, page, space):
        """
        Returns a attachments as a dictionary.

        :param page: The page name
        :type  page: ``str``

        :param space: The space name
        :type  space: ``str``

        :return: dictionary. result['content'] contains the body of the page.
        """
        if self._token2:
            server = self._server.confluence2
            token = self._token2
        else:
            server = self._server.confluence1
            token = self._token1
        existing_page = server.getPage(token, space, page)
        try:
            attachments = server.getAttachments(token, existing_page["id"])
        except xmlrpclib.Fault:
            logging.info("No existing attachment")
            attachments = None
        return attachments 
开发者ID:pycontribs,项目名称:confluence,代码行数:27,代码来源:confluence.py

示例9: getAttachedFileById

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def getAttachedFileById(self, id, fileName, version):
        """
        Returns a attachment data as byte[].

        :param id: The page id

        :param fileName: The attached file name
        :type  fileName: ``str``
        """
        if self._token2:
            server = self._server.confluence2
            token = self._token2
        else:
            server = self._server.confluence1
            token = self._token1
        try:
            DATA = server.getAttachmentData(token, id, fileName, version)
        except xmlrpclib.Fault:
            logging.info("No existing attachment")
            DATA = None
        return DATA 
开发者ID:pycontribs,项目名称:confluence,代码行数:23,代码来源:confluence.py

示例10: __connect

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def __connect(self):
        """
        This function establishes a connection to Spacewalk.
        """
        #set api session and key
        try:
            self.api_session = Server(self.url)
            self.api_key = self.api_session.auth.login(self.username, self.password)
        except Fault as err:
            if err.faultCode == 2950:
                raise InvalidCredentialsException(
                    "Wrong credentials supplied: '%s'", err.faultString
                )
            else:
                raise SessionException(
                    "Generic remote communication error: '%s'", err.faultString
                ) 
开发者ID:stdevel,项目名称:katprep,代码行数:19,代码来源:SpacewalkAPIClient.py

示例11: _cbRender

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def _cbRender(self, result, request, responseFailed=None):
        if responseFailed:
            return

        if isinstance(result, Handler):
            result = result.result
        if not isinstance(result, Fault):
            result = (result,)
        try:
            try:
                content = xmlrpclib.dumps(
                    result, methodresponse=True,
                    allow_none=self.allowNone)
            except Exception as e:
                f = Fault(self.FAILURE, "Can't serialize output: %s" % (e,))
                content = xmlrpclib.dumps(f, methodresponse=True,
                                          allow_none=self.allowNone)

            request.setHeader("content-length", str(len(content)))
            request.write(content)
        except:
            log.err()
        request.finish() 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:25,代码来源:xmlrpc.py

示例12: send_loop

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def send_loop(self):
		while True:
			await asyncio.sleep(0.25)
			if len(self.send_queue) == 0:
				continue

			# Copy send queue and clear the global one
			queue = self.send_queue.copy()
			self.send_queue.clear()

			# Process and push out the queue.
			try:
				await self.instance.gbx.multicall(*queue)
			except Fault as e:
				if 'Login unknown' in str(e):
					return
				logger.exception(e)
				handle_exception(exception=e, module_name=__name__, func_name='send_loop')
			except Exception as e:
				logger.exception(e)
				handle_exception(exception=e, module_name=__name__, func_name='send_loop') 
开发者ID:PyPlanet,项目名称:PyPlanet,代码行数:23,代码来源:__init__.py

示例13: handle_payload

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def handle_payload(self, handle_nr, method=None, data=None, fault=None):
		"""
		Handle a callback/response payload or fault.

		:param handle_nr: Handler ID
		:param method: Method name
		:param data: Parsed payload data.
		:param fault: Fault object.
		"""
		if handle_nr in self.handlers:
			await self.handle_response(handle_nr, method, data, fault)
		elif method and data is not None:
			if method == 'ManiaPlanet.ModeScriptCallbackArray':
				await self.handle_scripted(handle_nr, method, data)
			elif method == 'ManiaPlanet.ModeScriptCallback':
				await self.handle_scripted(handle_nr, method, data)
			else:
				await self.handle_callback(handle_nr, method, data)
		elif fault is not None:
			raise TransportException('Handle payload got invalid parameters, see fault exception! {}'.format(fault)) from fault
		else:
			print(method, handle_nr, data)
			logging.warning('Received gbx data, but handle wasn\'t known or payload invalid: handle_nr: {}, method: {}'.format(
				handle_nr, method,
			)) 
开发者ID:PyPlanet,项目名称:PyPlanet,代码行数:27,代码来源:remote.py

示例14: get_fabric_servers

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def get_fabric_servers(self, fabric_cnx=None):
        """Get all MySQL Fabric instances

        This method looks up the other MySQL Fabric instances which uses
        the same metadata. The returned list contains dictionaries with
        connection information such ass host and port. For example:

        [
            {'host': 'fabric_prod_1.example.com', 'port': 32274 },
            {'host': 'fabric_prod_2.example.com', 'port': 32274 },
        ]

        Returns a list of dictionaries
        """
        inst = fabric_cnx or self.get_instance()
        result = []
        err_msg = "Looking up Fabric servers failed using {host}:{port}: {err}"
        try:
            fset = inst.execute('dump', 'fabric_nodes',
                                "protocol." + self._protocol)

            for row in fset.rows():
                result.append({'host': row.host, 'port': row.port})
        except (Fault, socket.error) as exc:
            msg = err_msg.format(err=str(exc), host=inst.handler.host,
                                 port=inst.handler.port)
            raise InterfaceError(msg)
        except (TypeError, AttributeError) as exc:
            msg = err_msg.format(
                err="No Fabric server available ({0})".format(exc),
                host=inst.handler.host, port=inst.handler.port)
            raise InterfaceError(msg)

        try:
            fabric_uuid = uuid.UUID(fset.fabric_uuid_str)
        except TypeError:
            fabric_uuid = uuid.uuid4()

        fabric_version = 0

        return fabric_uuid, fabric_version, fset.ttl, result 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:43,代码来源:connection.py

示例15: render_POST

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Fault [as 别名]
def render_POST(self, request):
        request.content.seek(0, 0)
        request.setHeader(b"content-type", b"text/xml; charset=utf-8")
        try:
            args, functionPath = xmlrpclib.loads(request.content.read(),
                use_datetime=self.useDateTime)
        except Exception as e:
            f = Fault(self.FAILURE, "Can't deserialize input: %s" % (e,))
            self._cbRender(f, request)
        else:
            try:
                function = self.lookupProcedure(functionPath)
            except Fault as f:
                self._cbRender(f, request)
            else:
                # Use this list to track whether the response has failed or not.
                # This will be used later on to decide if the result of the
                # Deferred should be written out and Request.finish called.
                responseFailed = []
                request.notifyFinish().addErrback(responseFailed.append)
                if getattr(function, 'withRequest', False):
                    d = defer.maybeDeferred(function, request, *args)
                else:
                    d = defer.maybeDeferred(function, *args)
                d.addErrback(self._ebRender)
                d.addCallback(self._cbRender, request, responseFailed)
        return server.NOT_DONE_YET 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:29,代码来源:xmlrpc.py


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