diff --git a/chat_archiver/chat_archiver/ensure_emotes.py b/chat_archiver/chat_archiver/ensure_emotes.py new file mode 100644 index 0000000..4e968eb --- /dev/null +++ b/chat_archiver/chat_archiver/ensure_emotes.py @@ -0,0 +1,18 @@ + +import gevent.monkey +gevent.monkey.patch_all() + +import argh +import logging +import json + +from chat_archiver.main import ensure_emotes, wait_for_ensure_emotes + +def main(base_dir, *ids, log='INFO'): + """Ensure all listed emote ids are downloaded""" + logging.basicConfig(level=log) + ensure_emotes(base_dir, ids) + wait_for_ensure_emotes() + +if __name__ == '__main__': + argh.dispatch_command(main) diff --git a/chat_archiver/chat_archiver/main.py b/chat_archiver/chat_archiver/main.py index 6f4dfab..8df8b67 100644 --- a/chat_archiver/chat_archiver/main.py +++ b/chat_archiver/chat_archiver/main.py @@ -322,6 +322,10 @@ def ensure_emotes(base_dir, emote_ids): logging.debug("Skipping checking emote with key {} - already running".format(key)) +def wait_for_ensure_emotes(): + gevent.wait(_EMOTES_RUNNING.values()) + + def write_batch(path, batch_time, messages, size_histogram=None): """Batches are named PATH/YYYY-MM-DDTHH/MM:SS-HASH.json""" output = (format_batch(messages) + '\n').encode('utf-8')