• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rest.check_time_range函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.rest.check_time_range函数的典型用法代码示例。如果您正苦于以下问题:Python check_time_range函数的具体用法?Python check_time_range怎么用?Python check_time_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_time_range函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)

        statuses = rest_util.parse_string_list(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)
        error_categories = rest_util.parse_string_list(request, 'error_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_jobs(started=started, ended=ended, statuses=statuses, 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,
                                    include_superseded=include_superseded, order=order)

        page = self.paginate_queryset(jobs)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:droessne,项目名称:scale,代码行数:31,代码来源:views.py


示例2: list

    def list(self, request):
        """Retrieves the batches 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)
        recipe_type_ids = rest_util.parse_int_list(request, 'recipe_type_id', required=False)
        recipe_type_names = rest_util.parse_string_list(request, 'recipe_type_name', required=False)
        order = rest_util.parse_string_list(request, 'order', required=False)

        batches = Batch.objects.get_batches(started=started, ended=ended, statuses=statuses,
                                            recipe_type_ids=recipe_type_ids, recipe_type_names=recipe_type_names,
                                            order=order)

        page = self.paginate_queryset(batches)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:ngageoint,项目名称:scale,代码行数:25,代码来源:views.py


示例3: 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)

        job_status = rest_util.parse_string(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)

        order = rest_util.parse_string_list(request, 'order', required=False)

        jobs = Job.objects.get_job_updates(started, ended, job_status, job_type_ids, job_type_names,
                                           job_type_categories, 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:cuulee,项目名称:scale,代码行数:26,代码来源:views.py


示例4: list

    def list(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 = self.paginate_queryset(products)
        ProductFile.objects.populate_source_ancestors(page)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:cuulee,项目名称:scale,代码行数:27,代码来源:views.py


示例5: 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


示例6: get

    def get(self, request, name):
        '''Retrieves the plot values for metrics and return them 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)

        choice_ids = rest_util.parse_string_list(request, 'choice_id', required=False)
        column_names = rest_util.parse_string_list(request, 'column', required=False)
        group_names = rest_util.parse_string_list(request, 'group', required=False)

        try:
            provider = registry.get_provider(name)
            metrics_type = provider.get_metrics_type(include_choices=False)
        except MetricsTypeError:
            raise Http404

        # Build a unique set of column names from groups
        columns = metrics_type.get_column_set(column_names, group_names)

        # Get the actual plot values
        metrics_values = provider.get_plot_data(started, ended, choice_ids, columns)

        page = rest_util.perform_paging(request, metrics_values)

        if len(choice_ids) > 1:
            serializer = MetricsPlotMultiListSerializer(page, context={'request': request})
        else:
            serializer = MetricsPlotListSerializer(page, context={'request': request})
        return Response(serializer.data, status=status.HTTP_200_OK)
开发者ID:cshamis,项目名称:scale,代码行数:35,代码来源:views.py


示例7: get

    def get(self, request):
        """Retrieves the list of all recipe types 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)

        order = rest_util.parse_string_list(request, 'order', ['name', 'version'])

        recipe_types = RecipeType.objects.get_recipe_types(started, ended, order)

        page = self.paginate_queryset(recipe_types)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:AppliedIS,项目名称:scale,代码行数:19,代码来源:views.py


示例8: list

    def list(self, request):
        """Retrieves the ingest status information 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', rest_util.get_relative_days(7))
        ended = rest_util.parse_timestamp(request, 'ended', required=False)
        rest_util.check_time_range(started, ended, max_duration=datetime.timedelta(days=31))

        use_ingest_time = rest_util.parse_bool(request, 'use_ingest_time', default_value=False)

        ingests = Ingest.objects.get_status(started, ended, use_ingest_time)

        page = self.paginate_queryset(ingests)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:AppliedIS,项目名称:scale,代码行数:20,代码来源:views.py


示例9: list

    def list(self, request):
        """Retrieves the list of all nodes 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)
        include_inactive = rest_util.parse_bool(request, 'include_inactive', False, False)

        order = rest_util.parse_string_list(request, 'order', required=False)

        nodes = Node.objects.get_nodes(started, ended, order, include_inactive=include_inactive)

        page = self.paginate_queryset(nodes)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:droessne,项目名称:scale,代码行数:20,代码来源:views.py


示例10: 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


示例11: 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_status = rest_util.parse_string(request, 'status', 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_status, file_name, order)

        page = self.paginate_queryset(ingests)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:dancollar,项目名称:scale,代码行数:22,代码来源:views.py


示例12: list

    def list(self, request, name):
        """Retrieves the plot values for metrics and return them in JSON form

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :param name: the name of the metrics detail to retrieve.
        :type name: string
        :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)

        choice_ids = rest_util.parse_string_list(request, 'choice_id', required=False)
        column_names = rest_util.parse_string_list(request, 'column', required=False)
        group_names = rest_util.parse_string_list(request, 'group', required=False)

        try:
            provider = registry.get_provider(name)
            metrics_type = provider.get_metrics_type(include_choices=False)
        except MetricsTypeError:
            raise Http404

        # Build a unique set of column names from groups
        columns = metrics_type.get_column_set(column_names, group_names)

        # Get the actual plot values
        metrics_values = provider.get_plot_data(started, ended, choice_ids, columns)

        page = self.paginate_queryset(metrics_values)
        if len(choice_ids) > 1:
            serializer = MetricsPlotMultiSerializer(page, many=True)
        else:
            serializer = MetricsPlotSerializer(page, many=True)
        return self.get_paginated_response(serializer.data)
开发者ID:AppliedIS,项目名称:scale,代码行数:36,代码来源:views.py


示例13: get

    def get(self, request):
        """Retrieves the job load 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', default_value=rest_util.get_relative_days(7))
        ended = rest_util.parse_timestamp(request, 'ended', required=False)
        rest_util.check_time_range(started, ended, max_duration=datetime.timedelta(days=31))

        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)
        job_type_priorities = rest_util.parse_string_list(request, 'job_type_priority', required=False)

        job_loads = JobLoad.objects.get_job_loads(started, ended, job_type_ids, job_type_names, job_type_categories,
                                                  job_type_priorities)
        job_loads_grouped = JobLoad.objects.group_by_time(job_loads)

        page = rest_util.perform_paging(request, job_loads_grouped)
        serializer = JobLoadGroupListSerializer(page, context={'request': request})
        return Response(serializer.data, status=status.HTTP_200_OK)
开发者ID:dev-geo,项目名称:scale,代码行数:24,代码来源:views.py


示例14: test_check_time_range_partial

 def test_check_time_range_partial(self):
     '''Tests checking a partial time range is valid.'''
     self.assertTrue(rest_util.check_time_range(datetime.datetime(2015, 1, 1), None))
     self.assertTrue(rest_util.check_time_range(None, datetime.datetime(2015, 1, 30)))
开发者ID:dev-geo,项目名称:scale,代码行数:4,代码来源:test_rest.py


示例15: test_check_time_range

 def test_check_time_range(self):
     '''Tests checking a time range is valid.'''
     self.assertTrue(rest_util.check_time_range(datetime.datetime(2015, 1, 1), datetime.datetime(2015, 1, 30)))
开发者ID:dev-geo,项目名称:scale,代码行数:3,代码来源:test_rest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rest.get_url函数代码示例发布时间:2022-05-26
下一篇:
Python request.safe_get_host函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap