# HG changeset patch # User jpayne # Date 1719220235 14400 # Node ID 0b0e3e4376a7be206511fac520e43ab033b915be # Parent 49d672730d3e0b3e109dae5a2435a139a61e90d8 planemo upload diff -r 49d672730d3e -r 0b0e3e4376a7 snp-cache.py --- 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: