Mercurial > repos > jpayne > snp_pipeline
diff snp-cache.py @ 60:0b0e3e4376a7
planemo upload
author | jpayne |
---|---|
date | Mon, 24 Jun 2024 05:10:35 -0400 |
parents | 11296a86e01b |
children | fb44b003e29b |
line wrap: on
line diff
--- a/snp-cache.py Mon Jun 17 23:57:13 2024 -0400 +++ b/snp-cache.py Mon Jun 24 05:10:35 2024 -0400 @@ -2,8 +2,7 @@ from __future__ import print_function -import boto3 -from botocore.exceptions import ClientError, DataNotFoundError, NoCredentialsError, BotoCoreError + import argparse import subprocess @@ -101,12 +100,13 @@ with open(output, 'wb') as output_f: #lookup ID in table and get a FH to the resource try: + import boto3 api_key = os.environ.get('AWS_API_KEY', '') s3 = boto3.resource('s3').Bucket(CACHE_NAMESPACE) s3.download_fileobj(name, output_f) logging.getLogger('snp-cache.cache').info("cache hit on {name}, retrieved.".format(**locals())) - except (DataNotFoundError, NoCredentialsError, BotoCoreError, ClientError) as e: - if type(e) is DataNotFoundError: + except Exception as e: + if type(e) is not ImportError: logging.getLogger('snp-cache.cache').info("cache miss on {name}".format(**locals())) else: logging.getLogger('snp-cache.cache').error(e) @@ -121,7 +121,7 @@ cached = subprocess.check_output(command, shell=True) try: s3.upload_fileobj(BytesIO(cached), name) - except (ClientError, BotoCoreError) as e: + except Exception as e: logging.getLogger('snp-cache.cache').error('Error writing to cache:') logging.getLogger('snp-cache.cache').error(e) finally: