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


Python client.ProtocolError方法代码示例

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


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

示例1: test_add_tag_without_permissions

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def test_add_tag_without_permissions(self):
        unauthorized_user = UserFactory()
        unauthorized_user.set_password('api-testing')
        unauthorized_user.save()

        unauthorized_user.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(unauthorized_user, 'testplans.add_testplantag')

        rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username,
                                       'api-testing',
                                       '%s/xml-rpc/' % self.live_server_url).server

        with self.assertRaisesRegex(ProtocolError, '403 Forbidden'):
            rpc_client.TestPlan.add_tag(self.plans[0].pk, self.tag1.name)

        # tags were not modified
        tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag1.pk).exists()
        self.assertFalse(tag_exists) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:20,代码来源:test_testplan.py

示例2: update

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

示例3: _download_file

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def _download_file(self, proxy, subtitle_ids):
        """
        Tries to download byte data. If successful the data will be stored to a table in the database. Afterwards, that
        same data will be taken from that table and another table and written to a file.
        """
        download_data = dict()
        try:
            download_data = proxy.DownloadSubtitles(self.opensubs_token, subtitle_ids)
        except ProtocolError as e:
            download_data["status"] = e
            self.prompt_label.setText("There has been a ProtocolError during downloading")
        except ResponseNotReady as e:
            download_data["status"] = e
            self.prompt_label.setText("There has been a ResponseNotReady Error during downloading")

        if download_data["status"] == "200 OK":
            self._store_byte_data_to_db(download_data)
            self._get_stored_byte_data()
        else:
            self.prompt_label.setText("There was an error while trying to download your file: {}"
                                      .format(download_data["status"])) 
开发者ID:lukaabra,项目名称:SubCrawl,代码行数:23,代码来源:subtitles.py

示例4: is_unavailable_exception

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def is_unavailable_exception(e):
    '''Returns True if the given ProtocolError is the product of a server-side
       exception caused by the 'temporarily unavailable' response sometimes
       given by operations on non-blocking sockets.'''

    # sometimes we get a -1 error code and/or empty headers
    try:
        if e.errcode == -1 or e.headers is None:
            return True
        exc_mess = e.headers.get('X-exception')
    except AttributeError:
        # Ignore OSErrors here.
        exc_mess = str(e)

    if exc_mess and 'temporarily unavailable' in exc_mess.lower():
        return True 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_xmlrpc.py

示例5: test_multicall

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

示例6: test_non_existing_multicall

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

示例7: test_fail_with_info

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

示例8: request

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def request(self, host, handler, request_body, verbose):
        """
        Make an xmlrpc request.
        """
        client = self.session or requests
        headers = {'User-Agent': self.user_agent,
                   'Content-Type': 'text/xml',
                   }
        url = self._build_url(host, handler)
        try:
            resp = client.post(url, data=request_body, headers=headers, timeout=self.timeout)
        except ValueError:
            raise
        except Exception:
            raise # something went wrong
        else:
            try:
                resp.raise_for_status()
            except requests.RequestException as e:
                raise xmlrpc.ProtocolError(url, resp.status_code,
                    str(e), resp.headers)
            else:
                return self.parse_response(resp) 
开发者ID:ip-tools,项目名称:patzilla,代码行数:25,代码来源:requests_xmlrpclib.py

示例9: _run_and_ignore_connection_lost

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def _run_and_ignore_connection_lost(self):
        try:
            yield
        except RuntimeError as r:  # disconnection from remotelibrary
            if 'Connection to remote server broken:' in r.args[0]:
                logger.info('Connection died as expected')
                return
            raise
        except HandlerExecutionFailed as e:  # disconnection from xmlrpc wrapped in robot keyword
            if any(elem in e.args[0] for elem in ('Connection to remote server broken:', 'ProtocolError')):
                logger.info('Connection died as expected')
                return
            raise
        except ProtocolError as r:  # disconnection from xmlrpc in jython on some platforms
            logger.info('Connection died as expected')
            return 
开发者ID:robotframework,项目名称:remoteswinglibrary,代码行数:18,代码来源:RemoteSwingLibrary.py

示例10: test_basic

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [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:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:19,代码来源:test_xmlrpc.py

示例11: test_add_tag_without_permissions

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def test_add_tag_without_permissions(self):
        unauthorized_user = UserFactory()
        unauthorized_user.set_password('api-testing')
        unauthorized_user.save()

        unauthorized_user.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(unauthorized_user, 'testcases.add_testcasetag')

        rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username,
                                       'api-testing',
                                       '%s/xml-rpc/' % self.live_server_url).server

        with self.assertRaisesRegex(ProtocolError, '403 Forbidden'):
            rpc_client.TestCase.add_tag(self.testcase.pk, self.tag1.name)

        # tags were not modified
        tag_exists = TestCase.objects.filter(pk=self.testcase.pk, tag__pk=self.tag1.pk).exists()
        self.assertFalse(tag_exists) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:20,代码来源:test_testcase.py

示例12: test_remove_tag_without_permissions

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def test_remove_tag_without_permissions(self):
        unauthorized_user = UserFactory()
        unauthorized_user.set_password('api-testing')
        unauthorized_user.save()

        unauthorized_user.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(unauthorized_user, 'testcases.delete_testcasetag')

        rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username,
                                       'api-testing',
                                       '%s/xml-rpc/' % self.live_server_url).server

        with self.assertRaisesRegex(ProtocolError, '403 Forbidden'):
            rpc_client.TestCase.remove_tag(self.testcase.pk, self.tag0.name)

        # tags were not modified
        tag_exists = TestCase.objects.filter(pk=self.testcase.pk, tag__pk=self.tag0.pk).exists()
        self.assertTrue(tag_exists)

        tag_exists = TestCase.objects.filter(pk=self.testcase.pk, tag__pk=self.tag1.pk).exists()
        self.assertFalse(tag_exists) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:23,代码来源:test_testcase.py

示例13: test_remove_tag_without_permissions

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def test_remove_tag_without_permissions(self):
        unauthorized_user = UserFactory()
        unauthorized_user.set_password('api-testing')
        unauthorized_user.save()

        unauthorized_user.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(unauthorized_user, 'testplans.delete_testplantag')

        rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username,
                                       'api-testing',
                                       '%s/xml-rpc/' % self.live_server_url).server

        with self.assertRaisesRegex(ProtocolError, '403 Forbidden'):
            rpc_client.TestPlan.remove_tag(self.plans[0].pk, self.tag0.name)

        # tags were not modified
        tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag0.pk).exists()
        self.assertTrue(tag_exists)

        tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag1.pk).exists()
        self.assertFalse(tag_exists) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:23,代码来源:test_testplan.py

示例14: test_remove_case_without_permissions

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def test_remove_case_without_permissions(self):
        unauthorized_user = UserFactory()
        unauthorized_user.set_password('api-testing')
        unauthorized_user.save()

        unauthorized_user.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(unauthorized_user, 'testruns.delete_testexecution')

        rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username,
                                       'api-testing',
                                       '%s/xml-rpc/' % self.live_server_url).server

        with self.assertRaisesRegex(ProtocolError, '403 Forbidden'):
            rpc_client.TestRun.remove_case(self.test_run.pk, self.test_case.pk)

        exists = TestExecution.objects.filter(run=self.test_run.pk, case=self.test_case.pk).exists()
        self.assertTrue(exists) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:19,代码来源:test_testrun.py

示例15: test_add_tag_without_permissions

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import ProtocolError [as 别名]
def test_add_tag_without_permissions(self):
        unauthorized_user = UserFactory()
        unauthorized_user.set_password('api-testing')
        unauthorized_user.save()

        unauthorized_user.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(unauthorized_user, 'testruns.add_testruntag')

        rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username,
                                       'api-testing',
                                       '%s/xml-rpc/' % self.live_server_url).server

        with self.assertRaisesRegex(ProtocolError, '403 Forbidden'):
            rpc_client.TestRun.add_tag(self.test_runs[0].pk, self.tag0.name)

        # tags were not modified
        tag_exists = TestRun.objects.filter(pk=self.test_runs[0].pk, tag__pk=self.tag0.pk).exists()
        self.assertFalse(tag_exists) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:20,代码来源:test_testrun.py


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