From b1f4bb1a82327af7e5da3ac1134cb66a2e2dabc9 Mon Sep 17 00:00:00 2001 From: James Turk Date: Fri, 13 Apr 2012 14:25:33 -0400 Subject: [PATCH] signal now send_task's --- oyster/scripts/signal.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/oyster/scripts/signal.py b/oyster/scripts/signal.py index e936f68..f84db99 100644 --- a/oyster/scripts/signal.py +++ b/oyster/scripts/signal.py @@ -1,15 +1,15 @@ #!/usr/bin/env python import argparse +from celery.execute import send_task from oyster.core import kernel - def main(): parser = argparse.ArgumentParser( description='do a task for all documents in a doc_class', ) - parser.add_argument('function', type=str, help='path to function to apply') + parser.add_argument('task', type=str, help='task name to apply') parser.add_argument('doc_class', type=str, help='doc_class to apply function to') @@ -18,17 +18,8 @@ def main(): docs = kernel.db.tracked.find({'doc_class': args.doc_class}, timeout=False) print '%s docs in %s' % (docs.count(), args.doc_class) - path, func = args.function.rsplit('.', 1) - mod = __import__(path, fromlist=[func]) - func = getattr(mod, func) - for doc in docs: - try: - func(doc, kernel.get_last_version(doc)) - # make optional? - kernel.db.tracked.save(doc, safe=True) - except Exception as e: - print 'Error while processing %s: %s' % (doc, e) + send_task(task, doc['_id']) if __name__ == '__main__': main()