def _Archive(self):
    if (self._content_addressed and
        google_storage_helper.exists(self._upload_path, self._bucket)):
      return

    google_storage_helper.upload(
        self._upload_path, self.name, self._bucket, content_type=self._datatype)
Beispiel #2
0
    def _Archive(self):
        if (self._content_addressed and google_storage_helper.exists(
                self._upload_path, self._bucket)):
            return

        google_storage_helper.upload(self._upload_path,
                                     self.name,
                                     self._bucket,
                                     content_type=self._datatype)
Beispiel #3
0
  def _Archive(self):
    if (self._content_addressed and
        google_storage_helper.exists(self._upload_path, self._bucket)):
      return

    content_type = None
    if self._datatype == output_manager.Datatype.HTML:
      content_type = 'text/html'
    google_storage_helper.upload(
        self._upload_path, self.name, self._bucket, content_type)
def upload_directory_to_gs(local_path, bucket, gs_path, dry_run):
    if dry_run:
        print 'would have uploaded %s to %s' % (local_path, gs_path)
        return

    # -m does multithreaded uploads, which is needed because we upload multiple
    # files. -r copies the whole directory.
    google_storage_helper.upload(gs_path,
                                 local_path,
                                 bucket,
                                 gs_args=['-m'],
                                 command_args=['-r'])
  def _SaveScreenshot(self, device, screenshot_host_dir, screenshot_device_file,
                      test_name, results):
    if screenshot_host_dir:
      screenshot_host_file = os.path.join(
          screenshot_host_dir,
          '%s-%s.png' % (
              test_name,
              time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime())))
      if device.FileExists(screenshot_device_file.name):
        try:
          device.PullFile(screenshot_device_file.name, screenshot_host_file)
        finally:
          screenshot_device_file.close()

        logging.info(
            'Saved screenshot for %s to %s.',
            test_name, screenshot_host_file)
        if self._test_instance.gs_results_bucket:
          link = google_storage_helper.upload(
              google_storage_helper.unique_name(
                  'screenshot', device=device),
              screenshot_host_file,
              bucket=('%s/screenshots' %
                      self._test_instance.gs_results_bucket))
          for result in results:
            result.SetLink('post_test_screenshot', link)
  def _SaveScreenshot(self, device, screenshot_host_dir, screenshot_device_file,
                      test_name, results):
    if screenshot_host_dir:
      screenshot_host_file = os.path.join(
          screenshot_host_dir,
          '%s-%s.png' % (
              test_name,
              time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime())))
      if device.FileExists(screenshot_device_file.name):
        try:
          device.PullFile(screenshot_device_file.name, screenshot_host_file)
        finally:
          screenshot_device_file.close()

        logging.info(
            'Saved screenshot for %s to %s.',
            test_name, screenshot_host_file)
        if self._test_instance.gs_results_bucket:
          link = google_storage_helper.upload(
              google_storage_helper.unique_name(
                  'screenshot', device=device),
              screenshot_host_file,
              bucket=('%s/screenshots' %
                      self._test_instance.gs_results_bucket))
          for result in results:
            result.SetLink('post_test_screenshot', link)
Beispiel #7
0
def upload_to_google_bucket(html, bucket, dest):
    with tempfile.NamedTemporaryFile(suffix='.html') as temp_file:
        temp_file.write(html)
        temp_file.flush()
        return google_storage_helper.upload(name=dest,
                                            filepath=temp_file.name,
                                            bucket='%s/html' % bucket,
                                            content_type='text/html',
                                            authenticated_link=True)
def upload_to_google_bucket(html, bucket, dest):
  with tempfile.NamedTemporaryFile(suffix='.html') as temp_file:
    temp_file.write(html)
    temp_file.flush()
    return google_storage_helper.upload(
        name=dest,
        filepath=temp_file.name,
        bucket='%s/html' % bucket,
        content_type='text/html',
        authenticated_link=True)
Beispiel #9
0
def upload_screenshot_set(json_path, test_name, bucket, builder_name,
                          build_number):
    screenshot_set = ui_screenshot_set(json_path)
    if not screenshot_set:
        return None
    dest = google_storage_helper.unique_name(
        'screenshots_%s_%s_%s' % (test_name, builder_name, build_number),
        suffix='.json')
    with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
        temp_file.write(screenshot_set)
        temp_file.flush()
        return google_storage_helper.upload(name=dest,
                                            filepath=temp_file.name,
                                            bucket='%s/json' % bucket,
                                            content_type='application/json',
                                            authenticated_link=True)
def upload_screenshot_set(json_path, test_name, bucket, builder_name,
                          build_number):
  screenshot_set = ui_screenshot_set(json_path)
  if not screenshot_set:
    return None
  dest = google_storage_helper.unique_name(
    'screenshots_%s_%s_%s' % (test_name, builder_name, build_number),
    suffix='.json')
  with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
    temp_file.write(screenshot_set)
    temp_file.flush()
    return google_storage_helper.upload(
        name=dest,
        filepath=temp_file.name,
        bucket='%s/json' % bucket,
        content_type='application/json',
        authenticated_link=True)
 def _UploadTestArtifacts(self, device, test_artifacts_dir):
   # TODO(jbudorick): Reconcile this with the output manager once
   # https://codereview.chromium.org/2933993002/ lands.
   if test_artifacts_dir:
     with tempfile_ext.NamedTemporaryDirectory() as test_artifacts_host_dir:
       device.PullFile(test_artifacts_dir.name, test_artifacts_host_dir)
       with tempfile_ext.NamedTemporaryDirectory() as temp_zip_dir:
         zip_base_name = os.path.join(temp_zip_dir, 'test_artifacts')
         test_artifacts_zip = shutil.make_archive(
             zip_base_name, 'zip', test_artifacts_host_dir)
         link = google_storage_helper.upload(
             google_storage_helper.unique_name(
                 'test_artifacts', device=device),
             test_artifacts_zip,
             bucket='%s/test_artifacts' % (
                 self._test_instance.gs_test_artifacts_bucket))
         logging.info('Uploading test artifacts to %s.', link)
         return link
   return None
 def _UploadTestArtifacts(self, device, test_artifacts_dir):
   # TODO(jbudorick): Reconcile this with the output manager once
   # https://codereview.chromium.org/2933993002/ lands.
   if test_artifacts_dir:
     with tempfile_ext.NamedTemporaryDirectory() as test_artifacts_host_dir:
       device.PullFile(test_artifacts_dir.name, test_artifacts_host_dir)
       with tempfile_ext.NamedTemporaryDirectory() as temp_zip_dir:
         zip_base_name = os.path.join(temp_zip_dir, 'test_artifacts')
         test_artifacts_zip = shutil.make_archive(
             zip_base_name, 'zip', test_artifacts_host_dir)
         link = google_storage_helper.upload(
             google_storage_helper.unique_name(
                 'test_artifacts', device=device),
             test_artifacts_zip,
             bucket='%s/test_artifacts' % (
                 self._test_instance.gs_test_artifacts_bucket))
         logging.info('Uploading test artifacts to %s.', link)
         return link
   return None