Beispiel #1
0
def _main(report_category, directory_prefix):
  """Grabs coverage data from disk on a bot and publishes it.

     Args:
       report_category: The kind of coverage to report. The dashboard
           application decides what is acceptable here (see
           dashboard/add_coverage_data.py for more information).
      directory_prefix: This bot's coverage directory prefix. Generally a bot's
          coverage directories will have the form <prefix><build number>,
          like Linux32DBG_345.
  """
  dashboard = dashboard_connection.DashboardConnection(constants.CONSUMER_KEY)
  dashboard.read_required_files(constants.CONSUMER_SECRET_FILE,
                                constants.ACCESS_TOKEN_FILE)

  coverage_www_dir = constants.BUILD_BOT_COVERAGE_WWW_DIRECTORY
  www_dir_contents = os.listdir(coverage_www_dir)
  latest_build_directory = _find_latest_build_coverage(www_dir_contents,
                                                       coverage_www_dir,
                                                       directory_prefix)

  index_html_path = os.path.join(coverage_www_dir, latest_build_directory,
                                 'index.html')
  index_html_file = open(index_html_path)
  whole_file = index_html_file.read()

  line_coverage = _grab_coverage_percentage('Lines:', whole_file)
  function_coverage = _grab_coverage_percentage('Functions:', whole_file)
  branch_coverage = _grab_coverage_percentage('Branches:', whole_file)

  _report_coverage_to_dashboard(dashboard, line_coverage, function_coverage,
      branch_coverage, report_category)
def _main():
  dashboard = dashboard_connection.DashboardConnection(constants.CONSUMER_KEY)
  dashboard.read_required_files(constants.CONSUMER_SECRET_FILE,
                                constants.ACCESS_TOKEN_FILE)

  bot_to_status_mapping = _download_and_parse_build_status()
  bot_to_status_mapping = _filter_undesired_bots(bot_to_status_mapping, BOTS)

  dashboard.send_post_request(constants.ADD_BUILD_STATUS_DATA_URL,
                              bot_to_status_mapping)