本文整理汇总了Python中pinball.ui.data_builder.DataBuilder.get_file_content方法的典型用法代码示例。如果您正苦于以下问题:Python DataBuilder.get_file_content方法的具体用法?Python DataBuilder.get_file_content怎么用?Python DataBuilder.get_file_content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pinball.ui.data_builder.DataBuilder
的用法示例。
在下文中一共展示了DataBuilder.get_file_content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: file_content
# 需要导入模块: from pinball.ui.data_builder import DataBuilder [as 别名]
# 或者: from pinball.ui.data_builder.DataBuilder import get_file_content [as 别名]
def file_content(request):
try:
workflow = request.GET['workflow']
instance = request.GET['instance']
job = request.GET['job']
execution = int(request.GET['execution'])
log_type = request.GET['log_type']
if execution < 0:
return HttpResponseServerError(
'execution must not be negative; got ' + execution)
data_builder = DataBuilder(DbStore())
file_data = data_builder.get_file_content(workflow, instance, job,
execution, log_type)
except:
LOG.exception('')
return HttpResponseServerError(traceback.format_exc())
else:
return HttpResponse(file_data, mimetype='text/plain')
示例2: DataBuilderTestCase
# 需要导入模块: from pinball.ui.data_builder import DataBuilder [as 别名]
# 或者: from pinball.ui.data_builder.DataBuilder import get_file_content [as 别名]
#.........这里部分代码省略.........
'workflow_0', 'job_0')
self.assertEqual(2 * 2, len(executions))
exit_codes = [0, 0, 1, 1]
for execution in executions:
self.assertEqual('workflow_0', execution.workflow)
self.assertEqual('job_0', execution.job)
self.assertTrue(execution.info.startswith('some_command'))
exit_codes.remove(execution.exit_code)
self.assertEqual(2, len(execution.logs))
def test_get_execution_empty(self):
self.assertIsNone(self._data_builder.get_execution('does_not_exist',
'does_not_exist',
'does_not_exist',
0))
def test_get_execution(self):
self._add_tokens()
execution = self._data_builder.get_execution('workflow_0',
'instance_0',
'job_0',
1)
self.assertEqual('workflow_0', execution.workflow)
self.assertEqual('instance_0', execution.instance)
self.assertEqual('job_0', execution.job)
self.assertEqual(1, execution.execution)
self.assertEqual('some_command 1 some_args 1', execution.info)
self.assertEqual(1, execution.exit_code)
self.assertEqual(2, execution.start_time)
self.assertEqual(13, execution.end_time)
self.assertEqual(2, len(execution.logs))
@mock.patch('__builtin__.open')
def test_get_file_content_no_file(self, _):
self.assertEqual('',
self._data_builder.get_file_content('does_not_exist',
'does_not_exist',
'does_not_exist',
'does_not_exist',
'does_not_exist'))
@mock.patch('os.makedirs')
@mock.patch('__builtin__.open')
def test_get_file_content(self, open_mock, _):
generate_workflows(2, 2, 2, 2, 2, self._store)
file_mock = mock.MagicMock()
open_mock.return_value = file_mock
file_mock.__enter__.return_value = file_mock
file_mock.read.return_value = 'some_content'
content = self._data_builder.get_file_content('workflow_0',
'instance_0',
'job_0',
0,
'info')
self.assertEqual('some_content', content)
def test_get_token_paths_empty(self):
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(