コード例 #1
0
    def list(self, request):
        """Returns tasks results based on the filters.

    This endpoint is significantly slower than 'count'. Use 'count' when
    possible.
    """
        # TODO(maruel): Rename 'list' to 'results'.
        # TODO(maruel): Rename 'TaskList' to 'TaskResults'.
        logging.debug('%s', request)
        now = utils.utcnow()
        try:
            items, cursor = datastore_utils.fetch_page(
                self._query_from_request(request), request.limit,
                request.cursor)
        except ValueError as e:
            raise endpoints.BadRequestException(
                'Inappropriate filter for tasks/list: %s' % e)
        except datastore_errors.NeedIndexError as e:
            logging.error('%s', e)
            raise endpoints.BadRequestException(
                'Requires new index, ask admin to create one.')
        except datastore_errors.BadArgumentError as e:
            logging.error('%s', e)
            raise endpoints.BadRequestException(
                'This combination is unsupported, sorry.')
        return swarming_rpcs.TaskList(
            cursor=cursor,
            items=[
                message_conversion.task_result_to_rpc(
                    i, request.include_performance_stats) for i in items
            ],
            now=now)
コード例 #2
0
  def list(self, request):
    """Provides a list of available tasks."""
    logging.info('%s', request)
    state = request.state.name.lower()
    uses = sum([bool(request.tags), state != 'all'])
    if state != 'all':
      raise endpoints.BadRequestException(
          'Querying by state is not yet supported. '
          'Received argument state=%s.' % state)
    if uses > 1:
      raise endpoints.BadRequestException(
          'Only one of tag (1 or many) or state can be used.')

    # get the tasks
    try:
      start = message_conversion.epoch_to_datetime(request.start)
      end = message_conversion.epoch_to_datetime(request.end)
      items, cursor_str, state = task_result.get_result_summaries(
          request.tags, request.cursor, start, end, state, request.limit)
      return swarming_rpcs.TaskList(
          cursor=cursor_str,
          items=[message_conversion.task_result_to_rpc(i) for i in items])
    except ValueError as e:
      raise endpoints.BadRequestException(
          'Inappropriate limit for tasks/list: %s' % e)
コード例 #3
0
 def list(self, request):
     """Provides a list of available tasks."""
     logging.info('%s', request)
     try:
         start = message_conversion.epoch_to_datetime(request.start)
         end = message_conversion.epoch_to_datetime(request.end)
         now = utils.utcnow()
         query = task_result.get_result_summaries_query(
             start, end, request.sort.name.lower(),
             request.state.name.lower(), request.tags)
         items, cursor = datastore_utils.fetch_page(query, request.limit,
                                                    request.cursor)
     except ValueError as e:
         raise endpoints.BadRequestException(
             'Inappropriate filter for tasks/list: %s' % e)
     except datastore_errors.NeedIndexError as e:
         logging.error('%s', e)
         raise endpoints.BadRequestException(
             'Requires new index, ask admin to create one.')
     except datastore_errors.BadArgumentError as e:
         logging.error('%s', e)
         raise endpoints.BadRequestException(
             'This combination is unsupported, sorry.')
     return swarming_rpcs.TaskList(
         cursor=cursor,
         items=[message_conversion.task_result_to_rpc(i) for i in items],
         now=now)
コード例 #4
0
    def list(self, request):
        """Provides a list of available tasks."""
        state = request.state.name.lower()
        uses = sum(
            [request.name is not None,
             bool(request.tag), state != 'all'])
        if uses > 1:
            raise endpoints.BadRequestException(
                'Only one of name, tag (1 or many) or state can be used.')

        # get the tasks
        items, cursor_str, sort, state = task_result.get_tasks(
            request.name, request.tag, request.cursor, request.limit,
            request.sort, state)
        return swarming_rpcs.TaskList(
            cursor=cursor_str,
            items=[
                message_conversion.task_result_summary_from_dict(
                    utils.to_json_encodable(item)) for item in items
            ],
            limit=request.limit,
            sort=sort,
            state=state)