def get(self):
     auth.warmup()
     bot_code.get_swarming_bot_zip(self.request.host_url)
     bot_groups_config.warmup()
     utils.get_module_version_list(None, None)
     self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
     self.response.write('ok')
Esempio n. 2
0
def _yield_logs(start_time, end_time):
  """Yields logservice.RequestLogs for the requested time interval.

  Meant to be mocked in tests.
  """
  # If module_versions is not specified, it will default to the current version
  # on current module, which is not what we want.
  # TODO(maruel): Keep request.offset and use it to resume the query by using it
  # instead of using start_time/end_time.
  module_versions = utils.get_module_version_list(None, True)
  for request in logservice.fetch(
      start_time=start_time - 1 if start_time else start_time,
      end_time=end_time + 1 if end_time else end_time,
      include_app_logs=True,
      module_versions=module_versions):
    yield request
Esempio n. 3
0
def _yield_logs(start_time, end_time):
  """Yields logservice.RequestLogs for the requested time interval.

  Meant to be mocked in tests.
  """
  # If module_versions is not specified, it will default to the current version
  # on current module, which is not what we want.
  # TODO(maruel): Keep request.offset and use it to resume the query by using it
  # instead of using start_time/end_time.
  module_versions = utils.get_module_version_list(None, True)
  for request in logservice.fetch(
      start_time=start_time - 1 if start_time else start_time,
      end_time=end_time + 1 if end_time else end_time,
      include_app_logs=True,
      module_versions=module_versions):
    yield request
Esempio n. 4
0
    def get(self):
        """Reports the errors logged and ignored.

    Arguments:
      start: epoch time to start looking at. Defaults to the messages since the
             last email.
      end: epoch time to stop looking at. Defaults to now.
      modules: comma separated modules to look at.
      tainted: 0 or 1, specifying if desiring tainted versions. Defaults to 1.
    """
        # TODO(maruel): Be consistent about using either epoch or human readable
        # formatted datetime.
        end = int(float(self.request.get('end', 0)) or time.time())
        start = int(
            float(self.request.get('start', 0))
            or ui._get_default_start_time() or 0)
        modules = self.request.get('modules')
        if modules:
            modules = modules.split(',')
        tainted = bool(int(self.request.get('tainted', '1')))
        module_versions = utils.get_module_version_list(modules, tainted)
        errors, ignored, _end_time = logscraper.scrape_logs_for_errors(
            start, end, module_versions)

        params = {
            'errors':
            errors,
            'errors_count':
            sum(len(e.events) for e in errors),
            'errors_version_count':
            len(set(itertools.chain.from_iterable(e.versions
                                                  for e in errors))),
            'ignored':
            ignored,
            'ignored_count':
            sum(len(i.events) for i in ignored),
            'ignored_version_count':
            len(set(itertools.chain.from_iterable(i.versions
                                                  for i in ignored))),
            'xsrf_token':
            self.generate_xsrf_token(),
        }
        params.update(ui._get_template_env(start, end, module_versions))
        self.response.write(template.render('ereporter2/requests.html',
                                            params))
Esempio n. 5
0
 def get(self):
     """Sends email(s) containing the errors logged."""
     # Do not use self.request.host_url because it will be http:// and will point
     # to the backend, with an host format that breaks the SSL certificate.
     # TODO(maruel): On the other hand, Google Apps instances are not hosted on
     # appspot.com.
     host_url = 'https://%s.appspot.com' % app_identity.get_application_id()
     request_id_url = host_url + '/restricted/ereporter2/request/'
     report_url = host_url + '/restricted/ereporter2/report'
     recipients = self.request.get('recipients',
                                   acl.get_ereporter2_recipients())
     result = ui._generate_and_email_report(
         utils.get_module_version_list(None, False), recipients,
         request_id_url, report_url, {})
     self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
     if result:
         self.response.write('Success.')
     else:
         # Do not HTTP 500 since we do not want it to be retried.
         self.response.write('Failed.')
Esempio n. 6
0
 def get(self):
   """Sends email(s) containing the errors logged."""
   # Do not use self.request.host_url because it will be http:// and will point
   # to the backend, with an host format that breaks the SSL certificate.
   # TODO(maruel): On the other hand, Google Apps instances are not hosted on
   # appspot.com.
   host_url = 'https://%s.appspot.com' % app_identity.get_application_id()
   request_id_url = host_url + '/restricted/ereporter2/request/'
   report_url = host_url + '/restricted/ereporter2/report'
   recipients = self.request.get('recipients', acl.get_ereporter2_recipients())
   result = ui._generate_and_email_report(
       utils.get_module_version_list(None, False),
       recipients,
       request_id_url,
       report_url,
       {})
   self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
   if result:
     self.response.write('Success.')
   else:
     # Do not HTTP 500 since we do not want it to be retried.
     self.response.write('Failed.')
Esempio n. 7
0
  def get(self):
    """Reports the errors logged and ignored.

    Arguments:
      start: epoch time to start looking at. Defaults to the messages since the
             last email.
      end: epoch time to stop looking at. Defaults to now.
      modules: comma separated modules to look at.
      tainted: 0 or 1, specifying if desiring tainted versions. Defaults to 1.
    """
    # TODO(maruel): Be consistent about using either epoch or human readable
    # formatted datetime.
    end = int(float(self.request.get('end', 0)) or time.time())
    start = int(
        float(self.request.get('start', 0)) or
        ui._get_default_start_time() or 0)
    modules = self.request.get('modules')
    if modules:
      modules = modules.split(',')
    tainted = bool(int(self.request.get('tainted', '1')))
    module_versions = utils.get_module_version_list(modules, tainted)
    errors, ignored, _end_time = logscraper.scrape_logs_for_errors(
        start, end, module_versions)

    params = {
      'errors': errors,
      'errors_count': sum(len(e.events) for e in errors),
      'errors_version_count':
          len(set(itertools.chain.from_iterable(e.versions for e in errors))),
      'ignored': ignored,
      'ignored_count': sum(len(i.events) for i in ignored),
      'ignored_version_count':
          len(set(itertools.chain.from_iterable(i.versions for i in ignored))),
      'xsrf_token': self.generate_xsrf_token(),
    }
    params.update(ui._get_template_env(start, end, module_versions))
    self.response.write(template.render('ereporter2/requests.html', params))
Esempio n. 8
0
 def get(self):
   auth.warmup()
   bot_code.get_swarming_bot_zip(self.request.host_url)
   utils.get_module_version_list(None, None)
   self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
   self.response.write('ok')