Given a file name and a bucket, remove it from S3.

        There's no reason to keep the file hosted on S3 once its been made into a Lambda function, so we can delete it from S3.

        Returns True on success, False on failure.
332755
def remove_from_s3(self, file_name, bucket_name):
        
        try:
            self.s3_client.head_bucket(Bucket=bucket_name)
        except botocore.exceptions.ClientError as e:  # pragma: no cover
            # If a client error is thrown, then check that it was a 404 error.
            # If it was a 404 error, then the bucket does not exist.
            error_code = int(e.response['Error']['Code'])
            if error_code == 404:
                return False

        try:
            self.s3_client.delete_object(Bucket=bucket_name, Key=file_name)
            return True
        except (botocore.exceptions.ParamValidationError, botocore.exceptions.ClientError):  # pragma: no cover
            return False
725857
def delete_file(self, path):
        
        self.log.debug("S3contents.GenericManager: delete_file '%s'", path)
        if self.file_exists(path) or self.dir_exists(path):
            self.fs.rm(path)
        else:
            self.no_such_entity(path)
22039
def delete(self, bucket=None, ignore=False):
        

        # Make lists
        buckets = bucket
        if isinstance(bucket, six.string_types):
            buckets = [bucket]
        elif bucket is None:
            buckets = reversed(self.buckets)

        # Iterate
        tables = []
        for bucket in buckets:

            # Check existent
            if bucket not in self.buckets:
                if not ignore:
                    message = 'Bucket "%s" doesn\'t exist.' % bucket
                    raise tableschema.exceptions.StorageError(message)
                return

            # Remove from buckets
            if bucket in self.__descriptors:
                del self.__descriptors[bucket]

            # Add table to tables
            table = self.__get_table(bucket)
            tables.append(table)

        # Drop tables, update metadata
        self.__metadata.drop_all(tables=tables)
        self.__metadata.clear()
        self.__reflect()
916961
def delete(self):
        """"""
        if self.filename == ':memory:':
            return True
        try:
            os.remove(self.filename)
            return True
        except OSError:
            return False
607835
def purge_files(self, exclude_files=["index.html", "error.html"]):
        
        for chunk in utils.chunk_list(self._get_manifest_data(), 1000):
            try:
                self.s3.delete_objects(
                    Bucket=self.sitename,
                    Delete={
                        'Objects': [{"Key": f} for f in chunk
                                    if f not in exclude_files]
                    }
                )
            except Exception as ex:
                pass
166456
def delete(cls, bucket_id):
        
        bucket = cls.get(bucket_id)
        if not bucket or bucket.deleted:
            return False

        bucket.deleted = True
        return True
333120
def remove(self):
        
        ''' 
            
        '''
    
        title = '%s.remove' % self.__class__.__name__
    
    # request bucket delete 
        self.s3.delete_bucket(self.bucket_name)

    # return confirmation
        exit_msg = '%s collection has been removed from S3.' % self.bucket_name
        return exit_msg
351706
public boolean remove(String fileName) {
      writeLock.lock();
      try {
         return filenames.remove(fileName);
      } finally {
         writeLock.unlock();
      }
   }
167847
private boolean deleteFile(String filename) throws Exception {
        if (filename == null) {
            return false;
        }
        File file = new File(storeDir, filename);
        return Files.deleteIfExists(file.toPath());
    }
990238
private boolean removeFile(File f) {
        if (Utils.fileIsFile(f)) {
            return Utils.deleteFile(f);
        } else {
            //delete directory f..
            boolean ok = true;
            //remove all the children..
            File children[] = Utils.listFiles(f);
            if (children != null) {
                for (File child : children) {
                    ok &= removeFile(child);
                }
            }
            //once children are deleted, remove the directory
            if (ok) {
                ok &= Utils.deleteFile(f);
            }
            return ok;
        }
    }
813025
def destroy_s3_event(app, env, region):
    

    # TODO: how do we know which bucket to process if triggers dict is empty?
    # Maybe list buckets and see which has notification to that lambda defined?
    # TODO: buckets should be named the same as apps, what if one app has multiple buckets?
    # bucket = rules.get('bucket')
    generated = get_details(app=app, env=env)

    bucket = generated.s3_app_bucket()

    session = boto3.Session(profile_name=env, region_name=region)
    s3_client = session.client('s3')

    config = {}

    s3_client.put_bucket_notification_configuration(Bucket=bucket, NotificationConfiguration=config)
    LOG.debug("Deleted Lambda S3 notification")

    return True
309756
def delete(filething, delete_v1=True, delete_v2=True):
    

    f = filething.fileobj

    if delete_v1:
        tag, offset = find_id3v1(f)
        if tag is not None:
            f.seek(offset, 2)
            f.truncate()

    # technically an insize=0 tag is invalid, but we delete it anyway
    # (primarily because we used to write it)
    if delete_v2:
        f.seek(0, 0)
        idata = f.read(10)
        try:
            id3, vmaj, vrev, flags, insize = struct.unpack('>3sBBB4s', idata)
        except struct.error:
            pass
        else:
            insize = BitPaddedInt(insize)
            if id3 == b'ID3' and insize >= 0:
                delete_bytes(f, insize + 10, 0)
908418
def remove(self, filename):
        
        output = self.shell('rm', filename)
        # any output means rm failed.
        return False if output else True
328822
def delete(self, name):
        
        i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None))
        if entry is not None:
            logger.info("Deleting " + name)
            os.remove(str(entry['path']))
            del self._uploadCache[i]
            return entry
        else:
            logger.info("Unable to delete " + name + ", not found")
            return None
562100
def remove_s3_bucket():
    """"""
    logger.debug("[#] Removing S3 bucket")
    client = boto3.client("s3", region_name=PRIMARY_REGION)
    buckets = client.list_buckets()
    matches = [x for x in buckets.get('Buckets', list())
               if x['Name'].startswith(S3_BUCKET_NAME)]
    if len(matches) == 0:
        return
    match = matches.pop()['Name']
    try:
        response = client.list_objects_v2(
            Bucket=match,
        )
    except client.exceptions.NoSuchBucket:
        logger.info("[!] S3 bucket already deleted")
        return True

    while response['KeyCount'] > 0:
        logger.debug('[*] Deleting %d objects from bucket %s'
                     % (len(response['Contents']), match))
        response = client.delete_objects(
            Bucket=match,
            Delete={
                'Objects': [{'Key': obj['Key']} for obj in response['Contents']]
            }
        )
        response = client.list_objects_v2(
            Bucket=match,
        )

    logger.debug('[#] Deleting bucket %s' % match)
    response = client.delete_bucket(
        Bucket=match
    )
    logger.info("[#] Successfully deleted the S3 bucket")

    return response
713621
def delete_file(client, bucket, remote_path):
    """"""
    bucket = client.get_bucket(bucket)
    bucket.delete_blob(remote_path)
1005122
def remove_object(self, instance, bucket_name, object_name):
        
        url = '/buckets/{}/{}/{}'.format(instance, bucket_name, object_name)
        self._client.delete_proto(url)