本文整理汇总了Python中util.rest.parse_int_list函数的典型用法代码示例。如果您正苦于以下问题:Python parse_int_list函数的具体用法?Python parse_int_list怎么用?Python parse_int_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_int_list函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: list
def list(self, request):
"""Retrieves jobs and returns it in JSON form
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
"""
started = rest_util.parse_timestamp(request, 'started', required=False)
ended = rest_util.parse_timestamp(request, 'ended', required=False)
rest_util.check_time_range(started, ended)
job_status = rest_util.parse_string(request, 'status', required=False)
job_ids = rest_util.parse_int_list(request, 'job_id', required=False)
job_type_ids = rest_util.parse_int_list(request, 'job_type_id', required=False)
job_type_names = rest_util.parse_string_list(request, 'job_type_name', required=False)
job_type_categories = rest_util.parse_string_list(request, 'job_type_category', required=False)
order = rest_util.parse_string_list(request, 'order', required=False)
jobs = Job.objects.get_jobs(started, ended, job_status, job_ids, job_type_ids, job_type_names,
job_type_categories, order)
page = self.paginate_queryset(jobs)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
开发者ID:cuulee,项目名称:scale,代码行数:27,代码来源:views.py
示例2: get
def get(self, request):
"""Gets jobs and their associated latest execution
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
"""
started = rest_util.parse_timestamp(request, 'started', required=False)
ended = rest_util.parse_timestamp(request, 'ended', required=False)
rest_util.check_time_range(started, ended)
job_status = rest_util.parse_string(request, 'status', required=False)
job_ids = rest_util.parse_int_list(request, 'job_id', required=False)
job_type_ids = rest_util.parse_int_list(request, 'job_type_id', required=False)
job_type_names = rest_util.parse_string_list(request, 'job_type_name', required=False)
job_type_categories = rest_util.parse_string_list(request, 'job_type_category', required=False)
order = rest_util.parse_string_list(request, 'order', required=False)
jobs = Job.objects.get_jobs(started, ended, job_status, job_ids, job_type_ids, job_type_names,
job_type_categories, order)
page = rest_util.perform_paging(request, jobs)
# Add the latest execution for each matching job
paged_jobs = list(page.object_list)
job_exes_dict = JobExecution.objects.get_latest(page.object_list)
for job in paged_jobs:
job.latest_job_exe = job_exes_dict[job.id] if job.id in job_exes_dict else None
page.object_list = paged_jobs
serializer = JobWithExecutionListSerializer(page, context={'request': request})
return Response(serializer.data, status=status.HTTP_200_OK)
开发者ID:dev-geo,项目名称:scale,代码行数:33,代码来源:views.py
示例3: get
def get(self, request):
'''Gets job executions and their associated job_type id, name, and version
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
'''
started = rest_util.parse_timestamp(request, u'started', required=False)
ended = rest_util.parse_timestamp(request, u'ended', required=False)
rest_util.check_time_range(started, ended)
job_status = rest_util.parse_string(request, u'status', required=False)
job_type_ids = rest_util.parse_int_list(request, u'job_type_id', required=False)
job_type_names = rest_util.parse_string_list(request, u'job_type_name', required=False)
job_type_categories = rest_util.parse_string_list(request, u'job_type_category', required=False)
node_ids = rest_util.parse_int_list(request, u'node_id', required=False)
order = rest_util.parse_string_list(request, u'order', required=False)
job_exes = JobExecution.objects.get_exes(started, ended, job_status, job_type_ids, job_type_names,
job_type_categories, node_ids, order)
page = rest_util.perform_paging(request, job_exes)
serializer = JobExecutionListSerializer(page, context={u'request': request})
return Response(serializer.data, status=status.HTTP_200_OK)
开发者ID:Carl4,项目名称:scale,代码行数:27,代码来源:views.py
示例4: test_parse_int_list_post
def test_parse_int_list_post(self):
'''Tests parsing a required list of int parameters that are provided via POST.'''
request = MagicMock(Request)
request.DATA = QueryDict('', mutable=True)
request.DATA.setlist('test', ['1', '2'])
self.assertEqual(rest_util.parse_int_list(request, 'test'), [1, 2])
开发者ID:cshamis,项目名称:scale,代码行数:7,代码来源:test_rest.py
示例5: get
def get(self, request):
"""Retrieves the job updates for a given time range and returns it in JSON form
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
"""
started = rest_util.parse_timestamp(request, 'started', required=False)
ended = rest_util.parse_timestamp(request, 'ended', required=False)
rest_util.check_time_range(started, ended)
statuses = rest_util.parse_string_list(request, 'status', required=False)
job_type_ids = rest_util.parse_int_list(request, 'job_type_id', required=False)
job_type_names = rest_util.parse_string_list(request, 'job_type_name', required=False)
job_type_categories = rest_util.parse_string_list(request, 'job_type_category', required=False)
include_superseded = rest_util.parse_bool(request, 'include_superseded', required=False)
order = rest_util.parse_string_list(request, 'order', required=False)
jobs = Job.objects.get_job_updates(started=started, ended=ended, statuses=statuses, job_type_ids=job_type_ids,
job_type_names=job_type_names, job_type_categories=job_type_categories,
include_superseded=include_superseded, order=order)
page = self.paginate_queryset(jobs)
Job.objects.populate_input_files(page)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
开发者ID:droessne,项目名称:scale,代码行数:28,代码来源:views.py
示例6: get
def get(self, request):
'''Retrieves the product updates for a given time range and returns it in JSON form
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
'''
started = rest_util.parse_timestamp(request, u'started', required=False)
ended = rest_util.parse_timestamp(request, u'ended', required=False)
rest_util.check_time_range(started, ended)
job_type_ids = rest_util.parse_int_list(request, u'job_type_id', required=False)
job_type_names = rest_util.parse_string_list(request, u'job_type_name', required=False)
job_type_categories = rest_util.parse_string_list(request, u'job_type_category', required=False)
is_operational = rest_util.parse_bool(request, u'is_operational', required=False)
file_name = rest_util.parse_string(request, u'file_name', required=False)
order = rest_util.parse_string_list(request, u'order', required=False)
products = ProductFile.objects.get_products(started, ended, job_type_ids, job_type_names, job_type_categories,
is_operational, file_name, order)
page = rest_util.perform_paging(request, products)
ProductFile.objects.populate_source_ancestors(page)
serializer = ProductFileUpdateListSerializer(page, context={'request': request})
return Response(serializer.data, status=status.HTTP_200_OK)
开发者ID:cshamis,项目名称:scale,代码行数:26,代码来源:views.py
示例7: test_parse_int_list
def test_parse_int_list(self):
'''Tests parsing a required list of int parameters that is provided via GET.'''
request = MagicMock(Request)
request.QUERY_PARAMS = QueryDict('', mutable=True)
request.QUERY_PARAMS.setlist('test', ['1', '2'])
self.assertListEqual(rest_util.parse_int_list(request, 'test'), [1, 2])
开发者ID:dev-geo,项目名称:scale,代码行数:7,代码来源:test_rest.py
示例8: test_parse_int_list_accepted_all
def test_parse_int_list_accepted_all(self):
'''Tests parsing a list of int parameters where all values are acceptable.'''
request = MagicMock(Request)
request.QUERY_PARAMS = QueryDict('', mutable=True)
request.QUERY_PARAMS.setlist('test', ['1', '2'])
self.assertListEqual(rest_util.parse_int_list(request, 'test', accepted_values=[1, 2]), [1, 2])
开发者ID:dev-geo,项目名称:scale,代码行数:7,代码来源:test_rest.py
示例9: test_parse_int_list_optional
def test_parse_int_list_optional(self):
'''Tests parsing an optional list of int parameters that are missing.'''
request = MagicMock(Request)
request.QUERY_PARAMS = QueryDict('', mutable=True)
request.QUERY_PARAMS.update({
'test': '1',
})
self.assertListEqual(rest_util.parse_int_list(request, 'test2', required=False), [])
开发者ID:Carl4,项目名称:scale,代码行数:8,代码来源:test_rest.py
示例10: test_parse_int_list_default
def test_parse_int_list_default(self):
'''Tests parsing a required list of int parameters that are provided via default value.'''
request = MagicMock(Request)
request.QUERY_PARAMS = QueryDict('', mutable=True)
request.QUERY_PARAMS.update({
'test': '1',
})
self.assertEqual(rest_util.parse_int_list(request, 'test2', ['2', '3']), [2, 3])
开发者ID:Carl4,项目名称:scale,代码行数:8,代码来源:test_rest.py
示例11: test_parse_int_list_post
def test_parse_int_list_post(self):
"""Tests parsing a required list of int parameters that are provided via POST."""
request = MagicMock(Request)
request.data = QueryDict('', mutable=True)
request.data.update({
'test': ['1', '2']
})
self.assertEqual(rest_util.parse_int_list(request, 'test'), [1, 2])
开发者ID:ngageoint,项目名称:scale,代码行数:9,代码来源:test_rest.py
示例12: post
def post(self, request):
"""Increase max_tries, place it on the queue, and returns the new job information in JSON form
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:returns: the HTTP response to send back to the user
"""
started = rest_util.parse_timestamp(request, 'started', required=False)
ended = rest_util.parse_timestamp(request, 'ended', required=False)
rest_util.check_time_range(started, ended)
job_status = rest_util.parse_string(request, 'status', required=False)
job_ids = rest_util.parse_int_list(request, 'job_ids', required=False)
job_type_ids = rest_util.parse_int_list(request, 'job_type_ids', required=False)
job_type_names = rest_util.parse_string_list(request, 'job_type_names', required=False)
job_type_categories = rest_util.parse_string_list(request, 'job_type_categories', required=False)
error_categories = rest_util.parse_string_list(request, 'error_categories', required=False)
priority = rest_util.parse_int(request, 'priority', required=False)
# Fetch all the jobs matching the filters
job_status = [job_status] if job_status else job_status
jobs = Job.objects.get_jobs(started=started, ended=ended, statuses=job_status, job_ids=job_ids,
job_type_ids=job_type_ids, job_type_names=job_type_names,
job_type_categories=job_type_categories, error_categories=error_categories)
if not jobs:
raise Http404
# Attempt to queue all jobs matching the filters
requested_job_ids = {job.id for job in jobs}
Queue.objects.requeue_jobs(requested_job_ids, priority)
# Refresh models to get the new status information for all originally requested jobs
jobs = Job.objects.get_jobs(job_ids=requested_job_ids)
page = self.paginate_queryset(jobs)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
开发者ID:droessne,项目名称:scale,代码行数:39,代码来源:views.py
示例13: list
def list(self, request):
"""Retrieves the list of all recipes and returns it in JSON form
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
"""
started = rest_util.parse_timestamp(request, 'started', required=False)
ended = rest_util.parse_timestamp(request, 'ended', required=False)
rest_util.check_time_range(started, ended)
type_ids = rest_util.parse_int_list(request, 'type_id', required=False)
type_names = rest_util.parse_string_list(request, 'type_name', required=False)
include_superseded = rest_util.parse_bool(request, 'include_superseded', required=False)
order = rest_util.parse_string_list(request, 'order', required=False)
recipes = Recipe.objects.get_recipes(started=started, ended=ended, type_ids=type_ids, type_names=type_names,
include_superseded=include_superseded, order=order)
page = self.paginate_queryset(recipes)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
开发者ID:droessne,项目名称:scale,代码行数:23,代码来源:views.py
示例14: list
def list(self, request):
"""Retrieves the list of all ingests and returns it in JSON form
:param request: the HTTP GET request
:type request: :class:`rest_framework.request.Request`
:rtype: :class:`rest_framework.response.Response`
:returns: the HTTP response to send back to the user
"""
started = rest_util.parse_timestamp(request, 'started', required=False)
ended = rest_util.parse_timestamp(request, 'ended', required=False)
rest_util.check_time_range(started, ended)
ingest_statuses = rest_util.parse_string_list(request, 'status', required=False)
strike_ids = rest_util.parse_int_list(request, 'strike_id', required=False)
file_name = rest_util.parse_string(request, 'file_name', required=False)
order = rest_util.parse_string_list(request, 'order', required=False)
ingests = Ingest.objects.get_ingests(started, ended, ingest_statuses, strike_ids, file_name, order)
page = self.paginate_queryset(ingests)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
开发者ID:AppliedIS,项目名称:scale,代码行数:23,代码来源:views.py
示例15: test_parse_int_list_default
def test_parse_int_list_default(self):
'''Tests parsing a required list of int parameters that are provided via default value.'''
request = MagicMock(Request)
request.query_params = QueryDict('', mutable=True)
request.query_params.setlist('test', ['1'])
self.assertEqual(rest_util.parse_int_list(request, 'test2', ['2', '3']), [2, 3])
开发者ID:AppliedIS,项目名称:scale,代码行数:6,代码来源:test_rest.py
示例16: test_parse_int_list_optional
def test_parse_int_list_optional(self):
'''Tests parsing an optional list of int parameters that are missing.'''
request = MagicMock(Request)
request.query_params = QueryDict('', mutable=True)
request.query_params.setlist('test', ['1'])
self.assertListEqual(rest_util.parse_int_list(request, 'test2', required=False), [])
开发者ID:AppliedIS,项目名称:scale,代码行数:6,代码来源:test_rest.py
注:本文中的util.rest.parse_int_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论