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


Python ProviderError.anpaError方法代码示例

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


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

示例1: test_ingest_provider_closed_when_critical_error_raised

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
 def test_ingest_provider_closed_when_critical_error_raised(self):
     provider_name = 'AAP'
     provider = self._get_provider(provider_name)
     self.assertFalse(provider.get('is_closed'))
     provider_service = self._get_provider_service(provider)
     provider_service.provider = provider
     provider_service.close_provider(provider, ProviderError.anpaError())
     provider = self._get_provider(provider_name)
     self.assertTrue(provider.get('is_closed'))
开发者ID:MiczFlor,项目名称:superdesk-core,代码行数:11,代码来源:update_ingest_tests.py

示例2: process_anpa_category

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
def process_anpa_category(item, provider):
    try:
        anpa_categories = superdesk.get_resource_service('vocabularies').find_one(req=None, _id='categories')
        if anpa_categories:
            for anpa_category in anpa_categories['items']:
                if anpa_category['is_active'] is True \
                        and item['anpa-category']['qcode'].lower() == anpa_category['value'].lower():
                    item['anpa-category'] = {'qcode': item['anpa-category']['qcode'], 'name': anpa_category['name']}
                    break
    except Exception as ex:
        raise ProviderError.anpaError(ex, provider)
开发者ID:yukoff,项目名称:superdesk,代码行数:13,代码来源:update_ingest.py

示例3: process_anpa_category

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
def process_anpa_category(item, provider):
    try:
        anpa_categories = superdesk.get_resource_service("vocabularies").find_one(req=None, _id="categories")
        if anpa_categories:
            for anpa_category in anpa_categories["items"]:
                if (
                    anpa_category["is_active"] is True
                    and item["anpa-category"]["qcode"].lower() == anpa_category["value"].lower()
                ):
                    item["anpa-category"] = {"qcode": item["anpa-category"]["qcode"], "name": anpa_category["name"]}
                    break
    except Exception as ex:
        raise ProviderError.anpaError(ex, provider)
开发者ID:Flowdeeps,项目名称:superdesk-1,代码行数:15,代码来源:update_ingest.py

示例4: process_anpa_category

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
def process_anpa_category(item, provider):
    try:
        anpa_categories = superdesk.get_resource_service('vocabularies').find_one(req=None, _id='categories')
        if anpa_categories:
            for item_category in item['anpa_category']:
                for anpa_category in anpa_categories['items']:
                    if anpa_category['is_active'] is True \
                            and item_category['qcode'].lower() == anpa_category['qcode'].lower():
                        item_category['name'] = anpa_category['name']
                        # make the case of the qcode match what we hold in our dictionary
                        item_category['qcode'] = anpa_category['qcode']
                        break
    except Exception as ex:
        raise ProviderError.anpaError(ex, provider)
开发者ID:verifiedpixel,项目名称:superdesk-core,代码行数:16,代码来源:update_ingest.py

示例5: process_anpa_category

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
def process_anpa_category(item, provider):
    try:
        anpa_categories = superdesk.get_resource_service('vocabularies').find_one(req=None, _id='categories')
        if anpa_categories:
            for item_category in item['anpa_category']:
                mapped_category = [c for c in anpa_categories['items'] if
                                   c['is_active'] is True and item_category['qcode'].lower() == c['qcode'].lower()]
                # if the category is not known to the system remove it from the item
                if len(mapped_category) == 0:
                    item['anpa_category'].remove(item_category)
                else:
                    item_category['name'] = mapped_category[0]['name']
                    # make the case of the qcode match what we hold in our dictionary
                    item_category['qcode'] = mapped_category[0]['qcode']
    except Exception as ex:
        raise ProviderError.anpaError(ex, provider)
开发者ID:hlmnrmr,项目名称:superdesk-core,代码行数:18,代码来源:update_ingest.py

示例6: test_raise_anpaError

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
 def test_raise_anpaError(self):
     with assert_raises(ProviderError) as error_context:
         try:
             ex = Exception("Testing anpaError")
             raise ex
         except Exception:
             raise ProviderError.anpaError(ex, self.provider)
     exception = error_context.exception
     self.assertTrue(exception.code == 2005)
     self.assertTrue(exception.message == "Anpa category error")
     self.assertIsNotNone(exception.system_exception)
     self.assertEqual(exception.system_exception.args[0], "Testing anpaError")
     self.assertEqual(len(self.mock_logger_handler.messages['error']), 1)
     self.assertEqual(self.mock_logger_handler.messages['error'][0],
                      "ProviderError Error 2005 - Anpa category error: "
                      "Testing anpaError on channel TestProvider")
开发者ID:ancafarcas,项目名称:superdesk-core,代码行数:18,代码来源:errors_test.py

示例7: mock_update

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
 def mock_update(provider):
     raise ProviderError.anpaError()
开发者ID:MiczFlor,项目名称:superdesk-core,代码行数:4,代码来源:update_ingest_tests.py

示例8: TestProviderService

# 需要导入模块: from superdesk.errors import ProviderError [as 别名]
# 或者: from superdesk.errors.ProviderError import anpaError [as 别名]
from superdesk.errors import SuperdeskApiError, ProviderError
from superdesk.io import register_feeding_service, registered_feeding_services
from .tests import setup_providers, teardown_providers
from superdesk.io.feeding_services import FeedingService
from superdesk.io.commands.remove_expired_content import get_expired_items, RemoveExpiredContent
from superdesk.celery_task_utils import mark_task_as_not_running, is_task_running
from test_factory import SuperdeskTestCase


class TestProviderService(FeedingService):

    def _update(self, provider):
        return []


register_feeding_service('test', TestProviderService(), [ProviderError.anpaError(None, None).get_error_description()])


class CeleryTaskRaceTest(SuperdeskTestCase):

    def test_the_second_update_fails_if_already_running(self):
        provider = {'_id': 'abc', 'name': 'test provider', 'update_schedule': {'minutes': 1}}
        removed = mark_task_as_not_running(provider['name'], provider['_id'])
        self.assertFalse(removed)

        failed_to_mark_as_running = is_task_running(provider['name'], provider['_id'], {'minutes': 1})
        self.assertFalse(failed_to_mark_as_running, 'Failed to mark ingest update as running')

        failed_to_mark_as_running = is_task_running(provider['name'], provider['_id'], {'minutes': 1})
        self.assertTrue(failed_to_mark_as_running, 'Ingest update marked as running, possible race condition')
开发者ID:MiczFlor,项目名称:superdesk-core,代码行数:32,代码来源:update_ingest_tests.py


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