本文整理汇总了Python中pinball.ui.data_builder.DataBuilder.is_signal_set方法的典型用法代码示例。如果您正苦于以下问题:Python DataBuilder.is_signal_set方法的具体用法?Python DataBuilder.is_signal_set怎么用?Python DataBuilder.is_signal_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pinball.ui.data_builder.DataBuilder
的用法示例。
在下文中一共展示了DataBuilder.is_signal_set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: status
# 需要导入模块: from pinball.ui.data_builder import DataBuilder [as 别名]
# 或者: from pinball.ui.data_builder.DataBuilder import is_signal_set [as 别名]
def status(request):
try:
workflow = request.GET.get('workflow')
instance = request.GET.get('instance')
data_builder = DataBuilder(DbStore())
status = []
if data_builder.is_signal_set(workflow, instance, Signal.EXIT):
status = ['exiting']
elif data_builder.is_signal_set(workflow, instance, Signal.ABORT):
status = ['aborting']
elif data_builder.is_signal_set(workflow, instance, Signal.DRAIN):
status = ['draining']
if not _is_master_alive():
status.append('no master at %s:%d' % (socket.gethostname(),
PinballConfig.MASTER_PORT))
status_json = json.dumps(status)
except:
LOG.exception('')
return HttpResponseServerError(traceback.format_exc())
else:
return HttpResponse(status_json, mimetype='application/json')
示例2: DataBuilderTestCase
# 需要导入模块: from pinball.ui.data_builder import DataBuilder [as 别名]
# 或者: from pinball.ui.data_builder.DataBuilder import is_signal_set [as 别名]
#.........这里部分代码省略.........
self.assertRaises(PinballException,
self._data_builder.get_token_paths,
'')
def test_get_token_paths(self):
self._add_tokens()
token_paths = self._data_builder.get_token_paths(
'/workflow/workflow_0/instance_0/job/waiting/')
self.assertEqual(2, len(token_paths))
paths = ['/workflow/workflow_0/instance_0/job/waiting/job_0',
'/workflow/workflow_0/instance_0/job/waiting/job_1']
for token_path in token_paths:
self.assertEqual(1, token_path.count)
paths.remove(token_path.path)
self.assertEqual([], paths)
def test_get_token_empty(self):
self.assertRaises(PinballException,
self._data_builder.get_token,
'/does_not_exist')
def test_get_token(self):
self._add_tokens()
token = self._data_builder.get_token(
'/workflow/workflow_0/instance_0/job/waiting/job_0')
self.assertEqual('/workflow/workflow_0/instance_0/job/waiting/job_0',
token.name)
self.assertIsNone(token.owner)
self.assertIsNone(token.expiration_time)
self.assertEqual(0, token.priority)
self.assertIsNotNone(token.data)
def test_signal_not_set(self):
self.assertFalse(self._data_builder.is_signal_set('does_not_exist', 0,
Signal.DRAIN))
def test_signal_set(self):
self._add_tokens()
self.assertTrue(self._data_builder.is_signal_set('workflow_0', 0,
Signal.DRAIN))
# Workflow status should be the running instance
def test_workflow_data_from_instances_data1(self):
wf_instance_list = [
WorkflowInstanceData('wf', '22346', Status.ABORTED, 12346, 54321),
WorkflowInstanceData('wf', '22345', Status.RUNNING, 12345, None),
WorkflowInstanceData('wf', '22347', Status.SUCCESS, 12347, 12390),
WorkflowInstanceData('wf', '22348', Status.RUNNING, 12348, None),
]
wf_data = DataBuilder._workflow_data_from_instances_data(
wf_instance_list)
self.assertEquals(wf_data.workflow, 'wf')
self.assertEquals(wf_data.status, Status.RUNNING)
self.assertEquals(wf_data.last_instance, '22348')
self.assertEquals(wf_data.last_start_time, 12348)
self.assertEquals(wf_data.last_end_time, None)
self.assertEquals(wf_data.running_instance_number, 2)
# Workflow status should be the running instance even if some instance ended
# at sys.maxint time
def test_workflow_data_from_instances_data2(self):
wf_instance_list = [
WorkflowInstanceData('wf', '22346', Status.ABORTED, 12355, sys.maxint),
WorkflowInstanceData('wf', '22347', Status.SUCCESS, 12365, 12390),
WorkflowInstanceData('wf', '22345', Status.RUNNING, 12345, None),
]