本文整理汇总了Python中superdesk.errors.PublishQueueError.destination_group_not_found_error方法的典型用法代码示例。如果您正苦于以下问题:Python PublishQueueError.destination_group_not_found_error方法的具体用法?Python PublishQueueError.destination_group_not_found_error怎么用?Python PublishQueueError.destination_group_not_found_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类superdesk.errors.PublishQueueError
的用法示例。
在下文中一共展示了PublishQueueError.destination_group_not_found_error方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_close_subscriber_doesnt_close
# 需要导入模块: from superdesk.errors import PublishQueueError [as 别名]
# 或者: from superdesk.errors.PublishQueueError import destination_group_not_found_error [as 别名]
def test_close_subscriber_doesnt_close(self):
with self.app.app_context():
subscriber = self.app.data.find('subscribers', None, None)[0]
self.assertTrue(subscriber.get('is_active'))
PublishService().close_transmitter(subscriber, 'subscribers',
PublishQueueError.destination_group_not_found_error())
subscriber = self.app.data.find('subscribers', None, None)[0]
self.assertTrue(subscriber.get('is_active'))
self.assertIsNone(subscriber.get('last_closed'))
示例2: queue_transmission
# 需要导入模块: from superdesk.errors import PublishQueueError [as 别名]
# 或者: from superdesk.errors.PublishQueueError import destination_group_not_found_error [as 别名]
def queue_transmission(self, doc):
try:
if doc.get('destination_groups'):
any_channel_closed = False
destination_groups = self.resolve_destination_groups(doc.get('destination_groups'))
output_channels, selector_codes, format_types = \
self.resolve_output_channels(destination_groups.values())
for output_channel in output_channels.values():
if output_channel.get('is_active', True) is False:
any_channel_closed = True
subscribers = self.get_subscribers(output_channel)
if subscribers and subscribers.count() > 0:
formatter = get_formatter(output_channel['format'])
pub_seq_num, formatted_doc = formatter.format(doc, output_channel)
formatted_item = {'formatted_item': formatted_doc, 'format': output_channel['format'],
'item_id': doc['_id'], 'item_version': doc.get('last_version', 0),
'published_seq_num': pub_seq_num}
formatted_item_id = get_resource_service('formatted_item').post([formatted_item])[0]
publish_queue_items = []
for subscriber in subscribers:
for destination in subscriber.get('destinations', []):
publish_queue_item = dict()
publish_queue_item['item_id'] = doc['_id']
publish_queue_item['formatted_item_id'] = formatted_item_id
publish_queue_item['subscriber_id'] = subscriber['_id']
publish_queue_item['destination'] = destination
publish_queue_item['output_channel_id'] = output_channel['_id']
publish_queue_item['selector_codes'] = selector_codes.get(output_channel['_id'], [])
publish_queue_item['published_seq_num'] = pub_seq_num
publish_queue_item['publish_schedule'] = doc.get('publish_schedule', None)
publish_queue_item['publishing_action'] = doc.get(config.CONTENT_STATE, None)
publish_queue_item['unique_name'] = doc.get('unique_name', None)
publish_queue_item['content_type'] = doc.get('type', None)
publish_queue_item['headline'] = doc.get('headline', None)
publish_queue_items.append(publish_queue_item)
get_resource_service('publish_queue').post(publish_queue_items)
return any_channel_closed
else:
raise PublishQueueError.destination_group_not_found_error(
KeyError('Destination groups empty for article: {}'.format(doc['_id'])), None)
except:
raise
示例3: queue_transmission
# 需要导入模块: from superdesk.errors import PublishQueueError [as 别名]
# 或者: from superdesk.errors.PublishQueueError import destination_group_not_found_error [as 别名]
def queue_transmission(self, doc):
try:
if doc.get('destination_groups'):
destination_groups = self.resolve_destination_groups(doc.get('destination_groups'))
output_channels, selector_codes, format_types = \
self.resolve_output_channels(destination_groups.values())
for output_channel in output_channels.values():
subscribers = self.get_subscribers(output_channel)
if subscribers and subscribers.count() > 0:
formatter = get_formatter(output_channel['format'])
pub_seq_num, formatted_doc = formatter.format(doc, output_channel)
formatted_item = {'formatted_item': formatted_doc, 'format': output_channel['format'],
'item_id': doc['_id'], 'item_version': doc.get('last_version', 0),
'published_seq_num': pub_seq_num}
formatted_item_id = get_resource_service('formatted_item').post([formatted_item])[0]
publish_queue_items = []
for subscriber in subscribers:
for destination in subscriber.get('destinations', []):
publish_queue_item = dict()
publish_queue_item['item_id'] = doc['_id']
publish_queue_item['formatted_item_id'] = formatted_item_id
publish_queue_item['subscriber_id'] = subscriber['_id']
publish_queue_item['destination'] = destination
publish_queue_item['output_channel_id'] = output_channel['_id']
publish_queue_item['selector_codes'] = selector_codes.get(output_channel['_id'], [])
publish_queue_item['published_seq_num'] = pub_seq_num
publish_queue_items.append(publish_queue_item)
get_resource_service('publish_queue').post(publish_queue_items)
else:
raise PublishQueueError.destination_group_not_found_error(
KeyError('Destination groups empty for article: {}'.format(doc['_id'])), None)
except:
raise