当前位置: 首页>>代码示例>>Python>>正文


Python Key.delete方法代码示例

本文整理汇总了Python中boto.s3.connection.Key.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Key.delete方法的具体用法?Python Key.delete怎么用?Python Key.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.s3.connection.Key的用法示例。


在下文中一共展示了Key.delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bwa

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_bwa():
    work_dir = tempfile.mkdtemp()
    create_config(work_dir)
    create_manifest(work_dir)
    # Call Pipeline
    try:
        subprocess.check_call(
            [
                "toil-bwa",
                "run",
                os.path.join(work_dir, "jstore"),
                "--manifest",
                os.path.join(work_dir, "manifest.txt"),
                "--config",
                os.path.join(work_dir, "config.txt"),
                "--retryCount",
                "1",
            ]
        )
    finally:
        shutil.rmtree(work_dir)
        conn = S3Connection()
        b = Bucket(conn, "cgl-driver-projects")
        k = Key(b)
        k.key = "test/ci/ci_test.bam"
        k.delete()
开发者ID:heuermh,项目名称:toil-scripts,代码行数:28,代码来源:test_bwa_alignment.py

示例2: test_upload_and_download_with_encryption

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_upload_and_download_with_encryption(tmpdir):
    from toil_scripts.lib.urls import s3am_upload
    from toil_scripts.lib.urls import download_url
    from boto.s3.connection import S3Connection, Bucket, Key
    work_dir = str(tmpdir)
    # Create temporary encryption key
    key_path = os.path.join(work_dir, 'foo.key')
    subprocess.check_call(['dd', 'if=/dev/urandom', 'bs=1', 'count=32',
                           'of={}'.format(key_path)])
    # Create test file
    upload_fpath = os.path.join(work_dir, 'upload_file')
    with open(upload_fpath, 'wb') as fout:
        fout.write(os.urandom(1024))
    # Upload file
    s3_dir = 's3://cgl-driver-projects/test'
    s3am_upload(fpath=upload_fpath, s3_dir=s3_dir, s3_key_path=key_path)
    # Download the file
    url = 'https://s3-us-west-2.amazonaws.com/cgl-driver-projects/test/upload_file'
    download_url(url=url, name='download_file', work_dir=work_dir, s3_key_path=key_path)
    download_fpath = os.path.join(work_dir, 'download_file')
    assert os.path.exists(download_fpath)
    assert filecmp.cmp(upload_fpath, download_fpath)
    # Delete the Key
    conn = S3Connection()
    b = Bucket(conn, 'cgl-driver-projects')
    k = Key(b)
    k.key = 'test/upload_file'
    k.delete()
开发者ID:ImRichardLiu,项目名称:toil-scripts,代码行数:30,代码来源:test_urls.py

示例3: test_upload_and_download_with_encryption

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_upload_and_download_with_encryption(tmpdir):
    from toil_scripts.lib.urls import s3am_upload
    from toil_scripts.lib.urls import download_url
    from boto.s3.connection import S3Connection, Bucket, Key
    work_dir = str(tmpdir)
    # Create temporary encryption key
    key_path = os.path.join(work_dir, 'foo.key')
    subprocess.check_call(['dd', 'if=/dev/urandom', 'bs=1', 'count=32',
                           'of={}'.format(key_path)])
    # Create test file
    upload_fpath = os.path.join(work_dir, 'upload_file')
    with open(upload_fpath, 'wb') as fout:
        fout.write(os.urandom(1024))
    # Upload file
    random_key = os.path.join('test/', str(uuid4()), 'upload_file')
    s3_url = os.path.join('s3://cgl-driver-projects/', random_key)
    try:
        s3_dir = os.path.split(s3_url)[0]
        s3am_upload(fpath=upload_fpath, s3_dir=s3_dir, s3_key_path=key_path)
        # Download the file
        download_url(url=s3_url, name='download_file', work_dir=work_dir, s3_key_path=key_path)
        download_fpath = os.path.join(work_dir, 'download_file')
        assert os.path.exists(download_fpath)
        assert filecmp.cmp(upload_fpath, download_fpath)
    finally:
        # Delete the Key. Key deletion never fails so we don't need to catch any exceptions
        with closing(S3Connection()) as conn:
            b = Bucket(conn, 'cgl-driver-projects')
            k = Key(b)
            k.key = random_key
            k.delete()
开发者ID:cmarkello,项目名称:toil-scripts,代码行数:33,代码来源:test_urls.py

示例4: handle_DELETE

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def handle_DELETE(request):
    """ Handle file deletion requests. For this, we use the Amazon Python SDK,
    boto.
    """
    if boto:
        bucket_name = request.REQUEST.get('bucket')
        key_name = request.REQUEST.get('key')
        aws_bucket = S3.get_bucket(bucket_name, validate=False)
        aws_key = Key(aws_bucket, key_name)
        aws_key.delete()
        return make_response(200)
    else:
        return make_response(500)
开发者ID:ciaron,项目名称:djangofine,代码行数:15,代码来源:views.py

示例5: s3_delete

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def s3_delete(key=None):
    """ Route for deleting files off S3. Uses the SDK. """
    try:
        from boto.s3.connection import Key, S3Connection
        S3 = S3Connection(app.config.get("AWS_SERVER_PUBLIC_KEY"), 
            app.config.get("AWS_SERVER_SECRET_KEY"))
        request_payload = request.values
        bucket_name = request_payload.get('bucket')
        key_name = request_payload.get('key')
        aws_bucket = S3.get_bucket(bucket_name, validate=False)
        aws_key = Key(aws_bucket, key_name)
        aws_key.delete()
        return make_response('', 200)
    except ImportError:
        abort(500)
开发者ID:9px,项目名称:server-examples,代码行数:17,代码来源:app.py

示例6: test_exome

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_exome():
    workdir = tempfile.mkdtemp()
    create_config_and_manifest(workdir)
    # Call Pipeline
    try:
        base_command = ['toil-exome', 'run',
                        '--config', os.path.join(workdir, 'config-toil-exome.yaml'),
                        os.path.join(workdir, 'jstore')]
        # Run with manifest
        subprocess.check_call(base_command + ['--manifest', os.path.join(workdir, 'manifest-toil-exome.tsv')])
    finally:
        shutil.rmtree(workdir)
        conn = S3Connection()
        b = Bucket(conn, 'cgl-driver-projects')
        k = Key(b)
        k.key = 'test/ci/exome-ci-test.tar.gz'
        k.delete()
开发者ID:ImRichardLiu,项目名称:toil-scripts,代码行数:19,代码来源:test_exome.py

示例7: test_bwa

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_bwa(tmpdir):
    work_dir = str(tmpdir)
    create_config(work_dir)
    create_manifest(work_dir)
    subdir = '/mnt/ephemeral/toil-scripts/bwa'
    os.makedirs(os.path.join(subdir, 'workDir'))
    # Call Pipeline
    try:
        subprocess.check_call(['toil-bwa', 'run',
                               os.path.join(subdir, 'jstore'),
                               '--manifest', os.path.join(work_dir, 'manifest.txt'),
                               '--config', os.path.join(work_dir, 'config.txt'),
                               '--retryCount', '1',
                               '--workDir', os.path.join(subdir, 'workDir')])
    finally:
        shutil.rmtree(subdir)
        conn = S3Connection()
        b = Bucket(conn, 'cgl-driver-projects')
        k = Key(b)
        k.key = 'test/ci/ci_test.bam'
        k.delete()
开发者ID:boratonAJ,项目名称:toil-scripts,代码行数:23,代码来源:test_bwa_alignment.py

示例8: test_bwa

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_bwa(tmpdir):
    work_dir = str(tmpdir)
    create_config(work_dir)
    subdir = '/mnt/ephemeral/toil-scripts/bwa'
    os.makedirs(os.path.join(subdir, 'workDir'))
    # URLs for
    ref = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa'
    amb = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa.amb'
    ann = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa.ann'
    bwt = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa.bwt'
    fai = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa.fai'
    pac = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa.pac'
    sa = 'https://s3-us-west-2.amazonaws.com/cgl-pipeline-inputs/alignment/ci/hg38_chr6.fa.sa'
    # Call Pipeline
    try:
        subprocess.check_call(['python', '-m', 'toil_scripts.batch_alignment.bwa_alignment',
                               os.path.join(subdir, 'jstore'),
                               '--config', os.path.join(work_dir, 'config.txt'),
                               '--retryCount', '1',
                               '--s3-dir', 's3://cgl-driver-projects/test/ci',
                               '--workDir', os.path.join(subdir, 'workDir'),
                               '--ref', ref,
                               '--amb', amb,
                               '--ann', ann,
                               '--bwt', bwt,
                               '--fai', fai,
                               '--pac', pac,
                               '--sa', sa,
                               '--library', 'test',
                               '--file-size', '1G'])
    finally:
        shutil.rmtree(subdir)
        conn = S3Connection()
        b = Bucket(conn, 'cgl-driver-projects')
        k = Key(b)
        k.key = 'test/ci/ci_test.bam'
        k.delete()
开发者ID:jsteward2930,项目名称:toil-scripts,代码行数:39,代码来源:test_bwa_alignment.py

示例9: test_rnaseq_cgl

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_rnaseq_cgl(tmpdir):
    work_dir = str(tmpdir)
    create_config_and_manifest(work_dir)
    subdir = '/mnt/ephemeral/toil-scripts/rnaseq/'
    os.makedirs(os.path.join(subdir, 'workDir'))
    sample = 's3://cgl-pipeline-inputs/rnaseq_cgl/ci/chr6_sample.tar.gz'
    # Call Pipeline
    try:
        base_command = ['toil-rnaseq', 'run',
                        '--config', os.path.join(work_dir, 'toil-rnaseq.config'),
                        os.path.join(subdir, 'jstore'),
                        '--retryCount', '1',
                        '--workDir', os.path.join(subdir, 'workDir')]
        # Run with --samples
        subprocess.check_call(base_command + ['--samples', sample])
        # Run with manifest
        subprocess.check_call(base_command + ['--manifest', os.path.join(work_dir, 'toil-rnaseq-manifest.tsv')])
    finally:
        shutil.rmtree(subdir)
        conn = S3Connection()
        b = Bucket(conn, 'cgl-driver-projects')
        k = Key(b)
        k.key = 'test/ci/chr6_sample.tar.gz'
        k.delete()
开发者ID:jsteward2930,项目名称:toil-scripts,代码行数:26,代码来源:test_rnaseq_cgl.py

示例10: test_exome

# 需要导入模块: from boto.s3.connection import Key [as 别名]
# 或者: from boto.s3.connection.Key import delete [as 别名]
def test_exome(tmpdir):
    work_dir = str(tmpdir)
    create_config_and_manifest(work_dir)
    subdir = '/mnt/ephemeral/toil-scripts/exome/'
    os.makedirs(os.path.join(subdir, 'workDir'))
    # normal_bam = 's3://cgl-pipeline-inputs/exome/ci/chr6.normal.bam'
    # tumor_bam = 's3://cgl-pipeline-inputs/exome/ci/chr6.tumor.bam'
    # Call Pipeline
    try:
        base_command = ['toil-exome', 'run',
                        '--config', os.path.join(work_dir, 'toil-exome.config'),
                        os.path.join(subdir, 'jstore'),
                        '--workDir', os.path.join(subdir, 'workDir')]
        # Run with --samples
        # subprocess.check_call(base_command + ['--samples', sample])
        # Run with manifest
        subprocess.check_call(base_command + ['--manifest', os.path.join(work_dir, 'toil-exome-manifest.tsv')])
    finally:
        shutil.rmtree(subdir)
        conn = S3Connection()
        b = Bucket(conn, 'cgl-driver-projects')
        k = Key(b)
        k.key = 'test/ci/exome-ci-test.tar.gz'
        k.delete()
开发者ID:jsteward2930,项目名称:toil-scripts,代码行数:26,代码来源:test_exome.py


注:本文中的boto.s3.connection.Key.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。