summaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/harvest/harvest_common.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@archive.org>2020-02-14 17:55:39 +0000
committerbnewbold <bnewbold@archive.org>2020-02-14 17:55:39 +0000
commitc6d7107dc6d8e0925d8a314a64692751725faf78 (patch)
tree533f45d7b70eceb5d5d19d37e6a71adf0d5f124b /python/fatcat_tools/harvest/harvest_common.py
parent07fabec32aada55a75c064e5c1e01a46da30d854 (diff)
parenta1bbf612cef473af0410f9985d9e191a4000a0f5 (diff)
downloadfatcat-c6d7107dc6d8e0925d8a314a64692751725faf78.tar.gz
fatcat-c6d7107dc6d8e0925d8a314a64692751725faf78.zip
Merge branch 'martin-harvest-print' into 'master'
harvest: log state on startup and use stderr for diagnostics See merge request webgroup/fatcat!27
Diffstat (limited to 'python/fatcat_tools/harvest/harvest_common.py')
-rw-r--r--python/fatcat_tools/harvest/harvest_common.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/fatcat_tools/harvest/harvest_common.py b/python/fatcat_tools/harvest/harvest_common.py
index 78830a1c..310366bd 100644
--- a/python/fatcat_tools/harvest/harvest_common.py
+++ b/python/fatcat_tools/harvest/harvest_common.py
@@ -57,6 +57,10 @@ class HarvestState:
if catchup_days or start_date or end_date:
self.enqueue_period(start_date, end_date, catchup_days)
+ def __str__(self):
+ return '<HarvestState to_process={}, completed={}>'.format(
+ len(self.to_process), len(self.completed))
+
def enqueue_period(self, start_date=None, end_date=None, catchup_days=14):
"""
This function adds a time period to the "TODO" list, unless the dates
@@ -129,7 +133,7 @@ class HarvestState:
def fail_fast(err, msg):
if err:
raise KafkaException(err)
- print("Commiting status to Kafka: {}".format(kafka_topic))
+ print("Commiting status to Kafka: {}".format(kafka_topic), file=sys.stderr)
producer_conf = kafka_config.copy()
producer_conf.update({
'delivery.report.only.error': True,
@@ -154,7 +158,7 @@ class HarvestState:
if not kafka_topic:
return
- print("Fetching state from kafka topic: {}".format(kafka_topic))
+ print("Fetching state from kafka topic: {}".format(kafka_topic), file=sys.stderr)
def fail_fast(err, msg):
if err:
raise KafkaException(err)
@@ -191,4 +195,4 @@ class HarvestState:
# verify that we got at least to HWM
assert c >= hwm[1]
- print("... got {} state update messages, done".format(c))
+ print("... got {} state update messages, done".format(c), file=sys.stderr)