Skip to content

Commit

Permalink
pdf functionality in main method
Browse files Browse the repository at this point in the history
  • Loading branch information
bonniegee committed May 30, 2024
1 parent d6ba422 commit df84c9c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions crons/acfa_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def all_repos(self, acfa_api_token):
acfa_api_token, as_client, repo, self.parent_cache
).daily_update()


class UpdateRepository(object):
def __init__(self, acfa_api_token, as_client, repo, parent_cache):
self.export_params = {
Expand Down Expand Up @@ -70,6 +71,13 @@ def daily_update(self, timestamp=None):
ead_filepath = Path(self.ead_cache, f"as_ead_{bibid}.xml")
with open(ead_filepath, "w") as ead_file:
ead_file.write(ead_response.content.decode("utf-8"))
pdf_filepath = Path(self.pdf_cache, f"as_ead_{bibid}.pdf")
pdf_response = self.as_client.aspace.client.get(
f"/repositories/{self.repo.id}/resource_descriptions/{resource.id}.pdf",
params=self.export_params,
)
with open(pdf_filepath, "wb") as pdf_file:
pdf_file.write(pdf_response.content)
bibids.append(bibid)
except Exception as e:
print(bibid, e)
Expand Down Expand Up @@ -111,13 +119,3 @@ def update_index(self, bibids):
}
response = requests.post(url, json=json_data, headers=headers)
return response

def save_pdf(self, resource):
try:
pdf_response = self.as_client.aspace.client.get(
f"/repositories/{self.repo.id}/resource_descriptions/{resource.id}.pdf",
params=self.export_params,
)
except Exception as e:
pass

0 comments on commit df84c9c

Please sign in to comment.