本文整理汇总了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()
示例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()
示例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()
示例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)
示例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)
示例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()
示例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()
示例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()
示例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()
示例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()