Skip to content

Commit

Permalink
SFR-2384: Fulfill Manifest Pub Backlist S3 Bucket (#471)
Browse files Browse the repository at this point in the history
* SFR-2384: Fulfill Manifest Pub Backlist S3 Bucket

* Changed string to snake case

---------

Co-authored-by: Dmitri <[email protected]>
  • Loading branch information
mitri-slory and Dmitri authored Dec 10, 2024
1 parent 3f3256c commit fa1edf6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 5 additions & 7 deletions processes/file/fulfill_url_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class FulfillURLManifestProcess(CoreProcess):
def __init__(self, *args):
super(FulfillURLManifestProcess, self).__init__(*args[:4])

self.fullImport = self.process == 'complete'
self.full_import = self.process == 'complete'
self.start_timestamp = None

self.generateEngine()
self.createSession()

self.s3Bucket = os.environ['FILE_BUCKET']
self.s3_bucket = os.environ['FILE_BUCKET']
self.host = os.environ['DRB_API_HOST']
self.prefix = 'manifests/UofM/'
self.prefix = 'manifests/publisher_backlist/'
self.s3_manager = S3Manager()
self.s3_manager.createS3Client()

Expand Down Expand Up @@ -73,10 +73,8 @@ def update_metadata_object(self, metadata_object, bucket_name, curr_key):
metadata_json, counter = self.reading_order_fulfill(metadata_json, counter)
metadata_json, counter = self.resource_fulfill(metadata_json, counter)
metadata_json, counter = self.toc_fulfill(metadata_json, counter)
except (Exception, IndexError) as e:
logger.error(e)
except:
logger.error('One of the Link fulfill methods failed')
except Exception as e:
logger.exception(e)

if counter >= 4:
for link in metadata_json['links']:
Expand Down
5 changes: 3 additions & 2 deletions services/sources/publisher_backlist_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self):
self.s3_manager = S3Manager()
self.s3_manager.createS3Client()
self.s3_bucket = os.environ['FILE_BUCKET']
self.prefix = 'manifests/publisher_backlist'

self.airtable_auth_token = os.environ.get('AIRTABLE_KEY', None)

Expand Down Expand Up @@ -133,9 +134,9 @@ def store_pdf_manifest(self, record):

if media_type == 'application/pdf':
record_id = record.identifiers[0].split('|')[0]
manifest_path = 'manifests/{}/{}.json'.format(source, record_id)
manifest_path = f'{self.prefix}/{source}/{record_id}.json'
manifest_url = 'https://{}.s3.amazonaws.com/{}'.format(
self.s3Bucket, manifest_path
self.s3_bucket, manifest_path
)

manifest_json = self.generate_manifest(record, url, manifest_url)
Expand Down

0 comments on commit fa1edf6

Please sign in to comment.