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


Python xmlrpclib.Fault方法代码示例

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


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

示例1: execute

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

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

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

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

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def main():
    parser = get_parser(with_help=True)
    args = parser.parse_args()
    client = login(args.username, args.store)
    ResPartner = client.ResPartner
    ResUsers = client.ResUsers
    ResGroups = client.ResGroups
    grp_project_user = ResGroups.get('project.group_project_user')
    members_with_gh = ResPartner.search([('x_github_login', '!=', False),
                                         ('user_ids', '=', False)])
    if not members_with_gh:
        return
    for partner in ResPartner.browse(members_with_gh):
        try:
            user = ResUsers.create({'partner_id': partner.id,
                                    'login': partner.email,
                                    'groups_id': [(4, grp_project_user.id, 0)],
                                    })
        except xmlrpclib.Fault:
            print('unable to create user for partner %r (%s) : '
                  'probable email address issue' % (partner.x_github_login,
                                                    partner.id))
        else:
            print(u'created user %r for partner %r' % (user,
                                                       partner.x_github_login)) 
开发者ID:OCA,项目名称:maintainer-tools,代码行数:27,代码来源:oca_sync_users.py

示例6: system_multicall

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def system_multicall(self, call_list):
        """system.multicall([{'methodName': 'add', 'params': [2, 2]}, ...]) => \
[[4], ...]

        Allows the caller to package multiple XML-RPC calls into a single
        request.

        See http://www.xmlrpc.com/discuss/msgReader$1208
        """

        results = []
        for call in call_list:
            method_name = call['methodName']
            params = call['params']

            try:
                # XXX A marshalling error in any response will fail the entire
                # multicall. If someone cares they should fix this.
                results.append([self._dispatch(method_name, params)])
            except Fault, fault:
                results.append(
                    {'faultCode' : fault.faultCode,
                     'faultString' : fault.faultString}
                    )
            except: 
开发者ID:glmcdona,项目名称:meddle,代码行数:27,代码来源:SimpleXMLRPCServer.py

示例7: CallFunction

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

示例8: do_address_status

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_address_status(self, arg):
        """ Command to get the status of addresses known to Supvisors. """
        if self._upcheck():
            addresses = arg.split()
            if not addresses or "all" in addresses:
                try:
                    infos = self.supvisors().get_all_addresses_info()
                except xmlrpclib.Fault, e:
                    self.ctl.output('ERROR ({})'.format(e.faultString))
                else:
                    for info in infos:
                        self.output_address_info(info)
            else:
                for address in addresses:
                    try:
                        info = self.supvisors().get_address_info(address)
                    except xmlrpclib.Fault, e:
                        self.ctl.output('{}: ERROR ({})'.format(address, e.faultString))
                    else:
                        self.output_address_info(info) 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:supvisorsctl.py

示例9: do_application_rules

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_application_rules(self, arg):
        """ Command to get the application rules handled by Supvisors. """
        if self._upcheck():
            applications = arg.split()
            if not applications or "all" in applications:
                try:
                    applications = [application_info['application_name']
                        for application_info in self.supvisors().get_all_applications_info()]
                except xmlrpclib.Fault, e:
                    self.ctl.output('ERROR ({})'.format(e.faultString))
                    applications = []
            rules_list = []
            for application in applications:
                try:
                    rules = self.supvisors().get_application_rules(application)
                except xmlrpclib.Fault, e:
                    self.ctl.output('{}: ERROR ({})'.format(application, e.faultString))
                else:
                    rules_list.append(rules)
            # print results 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:supvisorsctl.py

示例10: do_sstatus

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_sstatus(self, arg):
        """ Command to get information about processes known to Supvisors. """
        if self._upcheck():
            processes = arg.split()
            if not processes or "all" in processes:
                try:
                    info_list = self.supvisors().get_all_process_info()
                except xmlrpclib.Fault, e:
                    self.ctl.output('ERROR ({})'.format(e.faultString))
                    info_list = []
            else:
                info_list = []
                for process in processes:
                    try:
                        info = self.supvisors().get_process_info(process)
                    except xmlrpclib.Fault, e:
                        self.ctl.output('{}: ERROR ({})'.format(process, e.faultString))
                    else:
                        info_list.extend(info)
            # print results 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:supvisorsctl.py

示例11: do_process_rules

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_process_rules(self, arg):
        """ Command to get the process rules handled by Supvisors. """
        if self._upcheck():
            processes = arg.split()
            if not processes or "all" in processes:
                try:
                    processes = ['{}:*'.format(application_info['application_name'])
                        for application_info in self.supvisors().get_all_applications_info()]
                except xmlrpclib.Fault, e:
                    self.ctl.output('ERROR ({})'.format(e.faultString))
                    processes = []
            rules_list = []
            for process in processes:
                try:
                    rules = self.supvisors().get_process_rules(process)
                except xmlrpclib.Fault, e:
                    self.ctl.output('{}: ERROR ({})'.format(process, e.faultString))
                else:
                    rules_list.extend(rules)
            # print results 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:supvisorsctl.py

示例12: do_conflicts

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_conflicts(self, arg):
        """ Command to get the conflicts detected by Supvisors. """
        if self._upcheck():
            try:
                conflicts = self.supvisors().get_conflicts()
            except xmlrpclib.Fault, e:
                self.ctl.output('ERROR ({})'.format(e.faultString))
            else:
                if conflicts:
                    max_appli = max(len(conflict['application_name'])
                        for conflict in conflicts) + 4
                    max_proc = max(len(conflict['process_name'])
                        for conflict in conflicts) + 4
                    template = '%(appli)-{}s%(proc)-{}s%(state)-12s%(addresses)s'.format(max_appli, max_proc)
                    for conflict in conflicts:
                        line = template % {'appli': conflict['application_name'],
                            'proc': conflict['process_name'],
                            'state': conflict['statename'],
                            'addresses': conflict['addresses']}
                        self.ctl.output(line) 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:supvisorsctl.py

示例13: do_start_process_args

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_start_process_args(self, arg):
        """ Command to start a process with a strategy, rules
        and additional arguments. """
        if self._upcheck():
            args = arg.split()
            if len(args) < 3:
                self.ctl.output('ERROR: start_process_args requires a strategy, '
                    'a program name and extra arguments')
                self.help_start_process_args()
                return
            strategy = StartingStrategies._from_string(args[0])
            if strategy is None:
                self.ctl.output('ERROR: unknown strategy for start_process_args.'
                    ' use one of {}'.format(StartingStrategies._strings()))
                self.help_start_process_args()
                return
            namespec = args[1]
            try:
                result = self.supvisors().start_process(strategy, namespec,
                    ' '.join(args[2:]))
            except xmlrpclib.Fault, e:
                self.ctl.output('{}: ERROR ({})'.format(namespec, e.faultString))
            else:
                self.ctl.output('{} started: {}'.format(namespec, result)) 
开发者ID:julien6387,项目名称:supvisors,代码行数:26,代码来源:supvisorsctl.py

示例14: do_stop_process

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_stop_process(self, arg):
        """ Command to stop processes with rules. """
        if self._upcheck():
            processes = arg.split()
            if not processes or "all" in processes:
                try:
                    processes = ['{}:*'.format(application_info['application_name'])
                        for application_info in self.supvisors().get_all_applications_info()]
                except xmlrpclib.Fault, e:
                    self.ctl.output('ERROR ({})'.format(e.faultString))
                    processes = []
            for process in processes:
                try:
                    self.supvisors().stop_process(process)
                except xmlrpclib.Fault, e:
                    self.ctl.output('{}: ERROR ({})'.format(process, e.faultString))
                else:
                    self.ctl.output('{} stopped'.format(process)) 
开发者ID:julien6387,项目名称:supvisors,代码行数:20,代码来源:supvisorsctl.py

示例15: do_conciliate

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Fault [as 别名]
def do_conciliate(self, arg):
        """ Command to conciliate conflicts (applicable with default USER strategy). """
        if self._upcheck():
            args = arg.split()
            if len(args) < 1:
                self.ctl.output('ERROR: conciliate requires a strategy')
                self.help_conciliate()
                return
            strategy = ConciliationStrategies._from_string(args[0])
            if strategy is None:
                self.ctl.output('ERROR: unknown strategy for conciliate. '
                    'use one of {}'.format(ConciliationStrategies._strings()))
                self.help_conciliate()
                return
            try:
                result = self.supvisors().conciliate(strategy)
            except xmlrpclib.Fault, e:
                self.ctl.output('ERROR ({})'.format(e.faultString))
            else:
                self.ctl.output('Conciliated: {}'.format(result)) 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:supvisorsctl.py


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