From cf6e9789c850de101e1d1800b743333eab50b70e Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 21 Nov 2018 10:01:39 -0800 Subject: oaipmh: handle NoRecordsMatch --- python/fatcat_tools/harvest/oaipmh.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'python/fatcat_tools/harvest') diff --git a/python/fatcat_tools/harvest/oaipmh.py b/python/fatcat_tools/harvest/oaipmh.py index c3cb90db..f5e3fe7a 100644 --- a/python/fatcat_tools/harvest/oaipmh.py +++ b/python/fatcat_tools/harvest/oaipmh.py @@ -94,11 +94,14 @@ class HarvestOaiPmhWorker: count = 0 with produce_topic.get_producer() as producer: - for item in records: - count += 1 - if count % 50 == 0: - print("... up to {}".format(count)) - producer.produce(item.raw.encode('utf-8'), partition_key=item.header.identifier.encode('utf-8')) + try: + for item in records: + count += 1 + if count % 50 == 0: + print("... up to {}".format(count)) + producer.produce(item.raw.encode('utf-8'), partition_key=item.header.identifier.encode('utf-8')) + except sickle.oaiexceptions.NoRecordsMatch: + print("WARN: no OAI-PMH records for this date: {} (UTC)".format(date_str)) def run(self, continuous=False): -- cgit v1.2.3