Python xmlrpclib.Fault() Examples
The following are 30
code examples of xmlrpclib.Fault().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xmlrpclib
, or try the search function
.
Example #1
Source File: confluence.py From confluence with MIT License | 6 votes |
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
Example #2
Source File: connection.py From python-mysql-pool with MIT License | 6 votes |
def execute(self, group, command, *args, **kwargs): """Executes the given command with XML-RPC protocol Executes the given command with the given parameters Returns an iterator to navigate to navigate through the result set returned by Fabric """ try: grp = getattr(self.handler.proxy, group) cmd = getattr(grp, command) except AttributeError as exc: raise ValueError("{group}.{command} not available ({err})".format( group=group, command=command, err=str(exc))) fab_set = None try: data = cmd(*args, **kwargs) fab_set = FabricSet(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
Example #3
Source File: SimpleXMLRPCServer.py From meddle with MIT License | 6 votes |
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:
Example #4
Source File: oca_sync_users.py From maintainer-tools with GNU Affero General Public License v3.0 | 6 votes |
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))
Example #5
Source File: SimpleXMLRPCServer.py From ironpython2 with Apache License 2.0 | 6 votes |
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:
Example #6
Source File: dokuwiki.py From python-dokuwiki with MIT License | 6 votes |
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)
Example #7
Source File: connection.py From python-mysql-pool with MIT License | 6 votes |
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
Example #8
Source File: connection.py From python-mysql-pool with MIT License | 6 votes |
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
Example #9
Source File: SimpleXMLRPCServer.py From BinderFilter with MIT License | 6 votes |
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:
Example #10
Source File: SimpleXMLRPCServer.py From oss-ftp with MIT License | 6 votes |
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:
Example #11
Source File: plaso_xmlrpc.py From plaso with Apache License 2.0 | 6 votes |
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
Example #12
Source File: SimpleXMLRPCServer.py From pmatic with GNU General Public License v2.0 | 6 votes |
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:
Example #13
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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
Example #14
Source File: connection.py From python-mysql-pool with MIT License | 6 votes |
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
Example #15
Source File: check_conciliation_strategy.py From supvisors with Apache License 2.0 | 6 votes |
def _create_database_conflicts(self): """ Create conflicts on database application. """ # start all movie_server programs on all addresses for address, proxy in self.proxies.items(): for idx in range(3): try: program = 'movie_server_0%d' % (idx + 1) proxy.supervisor.startProcess('database:' + program) except xmlrpclib.Fault, exc: self.assertEqual(Faults.ALREADY_STARTED, exc.faultCode) else: # confirm starting through events event = self._get_next_process_event() self.assertDictContainsSubset({'name': program, 'state': 10, 'address': address}, event) event = self._get_next_process_event() self.assertDictContainsSubset({'name': program, 'state': 20, 'address': address}, event) # check supvisors event: CONCILIATION state is expected
Example #16
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
def _upcheck(self): """ Check of the API versions. """ try: api = self.supvisors().get_api_version() if api != API_VERSION: self.ctl.output('ERROR: this version of supvisorsctl expects to talk to a server ' 'with API version %s, but the remote version is %s.' % (API_VERSION, api)) return False except xmlrpclib.Fault, e: if e.faultCode == xmlrpc.Faults.UNKNOWN_METHOD: self.ctl.output('ERROR: supervisord responded but did not recognize ' 'the supvisors namespace commands that supvisorsctl uses to control it. ' 'Please check that the [rpcinterface:supervisor] section is enabled ' 'in the configuration file (see sample.conf).') return False raise
Example #17
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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))
Example #18
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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))
Example #19
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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))
Example #20
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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)
Example #21
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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
Example #22
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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
Example #23
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 6 votes |
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)
Example #24
Source File: http.py From LibrERP with GNU Affero General Public License v3.0 | 5 votes |
def send(self, service_name, method, *args): import openerp import traceback import xmlrpclib code_string = "warning -- %s\n\n%s" try: return openerp.netsvc.dispatch_rpc(service_name, method, args) except openerp.osv.osv.except_osv, e: # TODO change the except to raise LibException instead of their emulated xmlrpc fault raise xmlrpclib.Fault(code_string % (e.name, e.value), '')
Example #25
Source File: main.py From LibrERP with GNU Affero General Public License v3.0 | 5 votes |
def restore(self, req, db_file, restore_pwd, new_db): try: data = base64.b64encode(db_file.read()) req.session.proxy("db").restore(restore_pwd, new_db, data) return '' except xmlrpclib.Fault, e: if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied': raise Exception("AccessDenied")
Example #26
Source File: test_xmlrpc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_repr(self): f = xmlrpclib.Fault(42, 'Test Fault') self.assertEqual(repr(f), "<Fault 42: 'Test Fault'>") self.assertEqual(repr(f), str(f))
Example #27
Source File: main.py From LibrERP with GNU Affero General Public License v3.0 | 5 votes |
def image(self, req, model, id, field, **kw): Model = req.session.model(model) context = req.session.eval_context(req.context) try: if not id: res = Model.default_get([field], context).get(field) else: res = Model.read([int(id)], [field], context)[0].get(field) image_data = base64.b64decode(res) except (TypeError, xmlrpclib.Fault): image_data = self.placeholder(req) return req.make_response(image_data, [ ('Content-Type', 'image/png'), ('Content-Length', len(image_data))])
Example #28
Source File: SimpleXMLRPCServer.py From meddle with MIT License | 5 votes |
def _marshaled_dispatch(self, data, dispatch_method = None, path = None): """Dispatches an XML-RPC method from marshalled (XML) data. XML-RPC methods are dispatched from the marshalled (XML) data using the _dispatch method and the result is returned as marshalled data. For backwards compatibility, a dispatch function can be provided as an argument (see comment in SimpleXMLRPCRequestHandler.do_POST) but overriding the existing method through subclassing is the preferred means of changing method dispatch behavior. """ try: params, method = xmlrpclib.loads(data) # generate response if dispatch_method is not None: response = dispatch_method(method, params) else: response = self._dispatch(method, params) # wrap response in a singleton tuple response = (response,) response = xmlrpclib.dumps(response, methodresponse=1, allow_none=self.allow_none, encoding=self.encoding) except Fault, fault: response = xmlrpclib.dumps(fault, allow_none=self.allow_none, encoding=self.encoding)
Example #29
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 5 votes |
def do_master(self, arg): """ Command to get the Supvisors master address. """ if self._upcheck(): try: address = self.supvisors().get_master_address() except xmlrpclib.Fault, e: self.ctl.output('ERROR ({})'.format(e.faultString)) else: self.ctl.output(address)
Example #30
Source File: supvisorsctl.py From supvisors with Apache License 2.0 | 5 votes |
def do_sstate(self, arg): """ Command to get the Supvisors state. """ if self._upcheck(): try: state = self.supvisors().get_supvisors_state() except xmlrpclib.Fault, e: self.ctl.output('ERROR ({})'.format(e.faultString)) else: template = '%(code)-3s%(state)-12s' line = template % {'code': state['statecode'], 'state': state['statename']} self.ctl.output(line)