importing celery tasks from djkarma
authorSeth Woodworth <seth@sethish.com>
Thu, 17 Jan 2013 20:10:27 +0000 (15:10 -0500)
committerSeth Woodworth <seth@sethish.com>
Thu, 17 Jan 2013 20:10:27 +0000 (15:10 -0500)
karmaworld/apps/notes/tasks.py [new file with mode: 0644]

diff --git a/karmaworld/apps/notes/tasks.py b/karmaworld/apps/notes/tasks.py
new file mode 100644 (file)
index 0000000..d27e8e6
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+# -*- coding:utf8 -*-
+# Copyright (C) 2012  FinalsClub Foundation
+
+from celery.task import task
+from karmaworld.apps.notes.gdrive import convert_with_google_drive
+
+@task
+def process_document(note):
+    """ Process a file with Google Drive
+        populates and saves the Note.html, Note.text
+
+        :note: A `karmaworld.apps.notes.models.Note` instance associated, document or pdf file
+        :returns: True on success, else False
+    """
+    print "Processing document: %s -- %s" % (note.id, note.name)
+    try:
+        convert_with_google_drive(note)
+    except Exception, e:
+        print "\terror processing doc: %s -- %s" % (note.id, note.name)
+        return False
+    return True