Upload artifacts to S3 and copy to correct path depending on strategy.
177421
def upload_artifacts(self):
        """"""
        deploy_strategy = self.properties["deploy_strategy"]

        mirror = False
        if deploy_strategy == "mirror":
            mirror = True

        self._upload_artifacts_to_path(mirror=mirror)
        if deploy_strategy == "highlander":
            self._sync_to_uri(self.s3_latest_uri)
        elif deploy_strategy == "canary":
            self._sync_to_uri(self.s3_canary_uri)
        elif deploy_strategy == "alpha":
            self._sync_to_uri(self.s3_alpha_uri)
        elif deploy_strategy == "mirror":
            pass  # Nothing extra needed for mirror deployments
        else:
            raise NotImplementedError
103192
def collect_local(self, path):
        
        for f in os.listdir(path):
            lpath = os.path.join(path, f)
            if not os.path.isfile(lpath):
                continue
            Artifact(self, lpath)
397042
def setup_pathing(self):
        """"""
        self.s3_version_uri = self._path_formatter(self.version)
        self.s3_latest_uri = self._path_formatter("LATEST")
        self.s3_canary_uri = self._path_formatter("CANARY")
        self.s3_alpha_uri = self._path_formatter("ALPHA")
        self.s3_mirror_uri = self._path_formatter("MIRROR")
171409
function copyAssets({ assetsDir }) {
  if (_shouldCopyAssets(assetsDir)) {
    fs.copySync(distDir, assetsDir, {
      filter: src => !/inline/.test(src)
    });
  }
}
99559
def insert_paths(self, cache_key, paths):
    """"""
    with self._tmpfile(cache_key, 'write') as tmp:
      self._artifact(tmp.name).collect(paths)
      yield self._store_tarball(cache_key, tmp.name)
495992
def _copy_across(self, rel_path, cb=None):
        """"""

        from . import copy_file_or_flo

        if not self.upstream.has(rel_path):

            if not self.alternate.has(rel_path):

                return None

            source = self.alternate.get_stream(rel_path)

            sink = self.upstream.put_stream(rel_path, metadata=source.meta)

            try:
                copy_file_or_flo(source, sink, cb=cb)
            except:
                self.upstream.remove(rel_path, propagate=True)
                raise

            source.close()
            sink.close()
1067952
def upload(remote_location, remotes=None, ignores=None,
           static_root="/static/", prefix="", dry_run=False):
    # pylint:disable=too-many-arguments
    
    if remotes is None:
        remotes, ignores = _resources_files(
            abs_paths=remote_location.startswith('s3://'))
    if remote_location.startswith('s3://'):
        from deployutils.s3 import S3Backend
        backend = S3Backend(remote_location,
            static_root=static_root, dry_run=dry_run)
        backend.upload(list_local(remotes, prefix), prefix)
    else:
        excludes = []
        if ignores:
            for ignore in ignores:
                excludes += ['--exclude', ignore]
        # -O omit to set mod times on directories to avoid permissions error.
        shell_command(['/usr/bin/rsync']
            + excludes + ['-pOthrRvz', '--rsync-path', '/usr/bin/rsync']
            + remotes + [remote_location], dry_run=dry_run)
773424
def file_upload(self, local_path, remote_path, l_st):
        """"""
        self.sftp.put(local_path, remote_path)
        self._match_modes(remote_path, l_st)
418061
def InitializeUpload(self, http_request, http=None, client=None):
        """"""
        if self.strategy is None:
            raise exceptions.UserError(
                'No upload strategy set; did you call ConfigureRequest?')
        if http is None and client is None:
            raise exceptions.UserError('Must provide client or http.')
        if self.strategy != RESUMABLE_UPLOAD:
            return
        http = http or client.http
        if client is not None:
            http_request.url = client.FinalizeTransferUrl(http_request.url)
        self.EnsureUninitialized()
        http_response = http_wrapper.MakeRequest(http, http_request,
                                                 retries=self.num_retries)
        if http_response.status_code != http_client.OK:
            raise exceptions.HttpError.FromResponse(http_response)

        self.__server_chunk_granularity = http_response.info.get(
            'X-Goog-Upload-Chunk-Granularity')
        url = http_response.info['location']
        if client is not None:
            url = client.FinalizeTransferUrl(url)
        self._Initialize(http, url)

        # Unless the user has requested otherwise, we want to just
        # go ahead and pump the bytes now.
        if self.auto_transfer:
            return self.StreamInChunks()
        return http_response
1191430
def upload(self, cmd: str, meta: dict):
        """"""
        index = os.path.join(self.cached_repo, self.INDEX_FILE)
        if os.path.exists(index):
            os.remove(index)
        self._log.info("Writing the new index.json ...")
        with open(index, "w") as _out:
            json.dump(self.contents, _out)
        git.add(self.cached_repo, [index])
        message = self.COMMIT_MESSAGES[cmd].format(**meta)
        if self.signoff:
            global_conf_path = os.path.expanduser("~/.gitconfig")
            if os.path.exists(global_conf_path):
                with open(global_conf_path, "br") as _in:
                    conf = ConfigFile.from_file(_in)
                    try:
                        name = conf.get(b"user", b"name").decode()
                        email = conf.get(b"user", b"email").decode()
                        message += self.DCO_MESSAGE.format(name=name, email=email)
                    except KeyError:
                        self._log.warning(
                            "Did not find name or email in %s, committing without DCO.",
                            global_conf_path)
            else:
                self._log.warning("Global git configuration file %s does not exist, "
                                  "committing without DCO.", global_conf_path)
        else:
            self._log.info("Committing the index without DCO.")
        git.commit(self.cached_repo, message=message)
        self._log.info("Pushing the updated index ...")
        # TODO: change when https://github.com/dulwich/dulwich/issues/631 gets addressed
        git.push(self.cached_repo, self.remote_url, b"master")
        if self._are_local_and_remote_heads_different():
            self._log.error("Push has failed")
            raise ValueError("Push has failed")
1033465
def upload_to_s3(self, key, filename):
        
        extra_args = {'ACL': self.acl}
        # determine the mimetype of the file
        guess = mimetypes.guess_type(filename)
        content_type = guess[0]
        encoding = guess[1]

        if content_type:
            extra_args['ContentType'] = content_type

        # add the gzip headers, if necessary
        if (self.gzip and content_type in self.gzip_content_types) or encoding == 'gzip':
            extra_args['ContentEncoding'] = 'gzip'

        # add the cache-control headers if necessary
        if content_type in self.cache_control:
            extra_args['CacheControl'] = ''.join((
                'max-age=',
                str(self.cache_control[content_type])
            ))

        # access and write the contents from the file
        if not self.dry_run:
            logger.debug("Uploading %s" % filename)
            if self.verbosity > 0:
                self.stdout.write("Uploading %s" % filename)
            s3_obj = self.s3_resource.Object(self.aws_bucket_name, key)
            s3_obj.upload_file(filename, ExtraArgs=extra_args)

        # Update counts
        self.uploaded_files += 1
        self.uploaded_file_list.append(filename)
1065459
def collect_s3(self):
        
        print('Collecting artifacts matching tag/sha %s from S3 bucket %s' % (self.gitref, s3_bucket))
        self.s3 = boto3.resource('s3')
        self.s3_bucket = self.s3.Bucket(s3_bucket)
        self.s3.meta.client.head_bucket(Bucket=s3_bucket)
        for key in self.s3_bucket.objects.all():
            self.collect_single_s3(key.key)

        for a in self.artifacts:
            a.download(self.dlpath)
1319011
def upload_to_s3(file_path, config):
    
    logging.info("Uploading file to S3 bucket: %s", config['s3_bucket_name'])
    s3 = boto3.resource('s3')
    s3_filename = config['s3_bucket_path'] + config['rendered_filename']
    s3.Bucket(config['s3_bucket_name']).upload_file(
        file_path, s3_filename, ExtraArgs={
            'ContentType': 'text/html', 'ACL': 'public-read'})
1187809
def deploy_to_s3(self):
        
        self.tempdir = tempfile.mkdtemp('s3deploy')

        for keyname, absolute_path in self.find_file_paths():
            self.s3_upload(keyname, absolute_path)

        shutil.rmtree(self.tempdir, True)
        return True
1062777
def s3(ctx, bucket_name, data_file, region):
    """"""
    if not ctx.data_file:
        ctx.data_file = data_file

    if not ctx.bucket_name:
        ctx.bucket_name = bucket_name

    if not ctx.region:
        ctx.region = region

    ctx.type = 's3'
28368
def _put_bucket_versioning(self):
        """"""
        status = 'Suspended'
        if self.s3props['versioning']['enabled']:
            status = 'Enabled'

        versioning_config = {
            'MFADelete': self.s3props['versioning']['mfa_delete'],
            'Status': status
        }

        _response = self.s3client.put_bucket_versioning(Bucket=self.bucket, VersioningConfiguration=versioning_config)
        LOG.debug('Response setting up S3 versioning: %s', _response)
        LOG.info('S3 versioning configuration updated')
1002998
def upload(ctx, yes=False):
    """"""
    import callee
    version = callee.__version__

    # check the packages version
    # TODO: add a 'release' to automatically bless a version as release one
    if version.endswith('-dev'):
        fatal("Can't upload a development version (%s) to PyPI!", version)

    # run the upload if it has been confirmed by the user
    if not yes:
        answer = input("Do you really want to upload to PyPI [y/N]? ")
        yes = answer.strip().lower() == 'y'
    if not yes:
        logging.warning("Aborted -- not uploading to PyPI.")
        return -2

    logging.debug("Uploading version %s to PyPI...", version)
    setup_py_upload = ctx.run('python setup.py sdist upload')
    if not setup_py_upload.ok:
        fatal("Failed to upload version %s to PyPI!", version,
              cause=setup_py_upload)
    logging.info("PyPI upload completed successfully.")

    # add a Git tag and push
    git_tag = ctx.run('git tag %s' % version)
    if not git_tag.ok:
        fatal("Failed to add a Git tag for uploaded version %s", version,
              cause=git_tag)
    git_push = ctx.run('git push && git push --tags')
    if not git_push.ok:
        fatal("Failed to push the release upstream.", cause=git_push)