<commit_before>#!/usr/bin/env python
# Copyright (c) 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Uploads the results of render_skps.py."""

import os
import sys

from build_step import BuildStep
from utils import gs_utils

# TODO(epoger): Move these bucket names into global_variables.
GS_IMAGES_BUCKET    = 'gs://chromium-skia-skp-images'
GS_SUMMARIES_BUCKET = 'gs://chromium-skia-skp-summaries'


class UploadRenderedSKPs(BuildStep):

  def __init__(self, attempts=3, **kwargs):
    super(UploadRenderedSKPs, self).__init__(
        attempts=attempts, **kwargs)

  def _Run(self):
    gs = gs_utils.GSUtils()

    # Upload individual image files to Google Storage.
    #
    # Use UploadIf.IF_NEW so we don't re-upload image files we already have in
    # Google Storage (we use checksum-based filenames, so if there is already a
    # file with a given name, we know its contents are up-to-date).
    src_dir = os.path.abspath(self.playback_actual_images_dir)
    dest_bucket = gs.without_gs_prefix(GS_IMAGES_BUCKET)
    if os.listdir(src_dir):
      print 'Uploading image files from %s to gs://%s/' % (
          src_dir, dest_bucket)
      gs.upload_dir_contents(
          source_dir=src_dir, dest_bucket=dest_bucket, dest_dir=None,
          upload_if=gs.UploadIf.IF_NEW,
          predefined_acl=gs.PLAYBACK_CANNED_ACL,
          fine_grained_acl_list=gs.PLAYBACK_FINEGRAINED_ACL_LIST)
    else:
      print ('Skipping upload to Google Storage, because no image files in %s' %
             src_dir)

    # Upload image summaries (checksums) to Google Storage.
    #
    # It's important to only upload each summary file if it has changed,
    # because we use the history of the file in Google Storage to tell us
    # when any of the results changed.<commit_msg>upload images using IF_MODIFIED, just in case an image was corrupted during previous upload<commit_after>#!/usr/bin/env python
# Copyright (c) 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Uploads the results of render_skps.py."""

import os
import sys

from build_step import BuildStep
from utils import gs_utils

# TODO(epoger): Move these bucket names into global_variables.
GS_IMAGES_BUCKET    = 'gs://chromium-skia-skp-images'
GS_SUMMARIES_BUCKET = 'gs://chromium-skia-skp-summaries'


class UploadRenderedSKPs(BuildStep):

  def __init__(self, attempts=3, **kwargs):
    super(UploadRenderedSKPs, self).__init__(
        attempts=attempts, **kwargs)

  def _Run(self):
    gs = gs_utils.GSUtils()

    # Upload any new image files to Google Storage.
    #
    # TODO(epoger): We use checksum-based filenames, so we ought to be able to
    # use UploadIf.IF_NEW... but just in case any of the files was corrupted
    # in a previous upload, we use IF_MODIFIED for now.
    src_dir = os.path.abspath(self.playback_actual_images_dir)
    dest_bucket = gs.without_gs_prefix(GS_IMAGES_BUCKET)
    if os.listdir(src_dir):
      print 'Uploading image files from %s to gs://%s/' % (
          src_dir, dest_bucket)
      gs.upload_dir_contents(
          source_dir=src_dir, dest_bucket=dest_bucket, dest_dir=None,
          upload_if=gs.UploadIf.IF_MODIFIED,
          predefined_acl=gs.PLAYBACK_CANNED_ACL,
          fine_grained_acl_list=gs.PLAYBACK_FINEGRAINED_ACL_LIST)
    else:
      print ('Skipping upload to Google Storage, because no image files in %s' %
             src_dir)

    # Upload image summaries (checksums) to Google Storage.
    #
    # It's important to only upload each summary file if it has changed,
    # because we use the history of the file in Google Storage to tell us
    # when any of the results changed.
{'fraction_non_alphanumeric': 0.08174458083050405, 'fraction_numerical': 0.0026116479498563593, 'mean_word_length': 3.4380069524913095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5893424', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1232, 'n_words': 391}