Permalink
Browse files

Still working on celery

  • Loading branch information...
1 parent aa49b6d commit 0929bf9a771d7a3da9ea4d88de93047ff59fcfc1 @emperorcezar emperorcezar committed Jul 30, 2012
Showing with 31 additions and 13 deletions.
  1. +1 −0 wander/.#celery.py
  2. +25 −4 wander/__init__.py
  3. +1 −3 wander/celery.py
  4. +0 −3 wander/mail.py
  5. +4 −3 wander/tasks.py
View
View
@@ -11,6 +11,10 @@
from gdata.apps import client
+from wander.tasks import pull
+
+__all__ = ['imap_connect']
+
def get_user_info(fabric_settings, user, desired_info):
command = fabric_settings['zmprov_path'] + ' ga '+ user
for i in desired_info:
@@ -159,12 +163,29 @@ def get_mail(settings, userfile):
'''
For each user, get a list of message ids and send them to celery to process
'''
+
+ import pdb; pdb.set_trace()
+
with open(userfile[0]) as f:
for user in f.readlines():
- imap = imap_connect(settings, user)
- print imap.list()
-
-
+ imap = imap_connect(settings, user.strip())
+ response_code, raw_folder_list = imap.list()
+ all_ids = []
+ for folder in raw_folder_list:
+ # parse
+ folder = folder.split('"')[1::2][1]
+ if folder in ['Contacts', 'Chats', 'Emailed Contacts']:
+ continue
+
+ # Get all the message uids
+ imap.select(folder, True)
+ response_code, ids = imap.uid('search', None, 'ALL')
+ for id in ids[0].split():
+ pull.delay(folder, messageid)
+
+ print len(all_ids)
+
+
def auth_google(settings):
google_client = client.AppsClient(domain=settings['domain'])
google_client.ssl = True
View
@@ -1,3 +1 @@
-from celery import Celery
-
-celery = Celery(broker='mongodb://localhost:27017/database_name')
+#celery = Celery(broker='mongodb://localhost:27017/database_name')
View
@@ -1,6 +1,3 @@
-from wander import imap_connect
-from wander import auth_google
-
from mongoengine import *
View
@@ -1,12 +1,13 @@
-from wander.celery import celery
from wander.mail import StoredMessage
+celery = Celery(broker='mongodb://localhost:27017/database_name')
+
@celery.task
-def pull(messageid):
+def pull(folder, messageid):
'''
Pulls a message from zimbra and stores it in Mongo
'''
- pass
+ print "Pull {}".format()
@celery.task
def push(messageid):

0 comments on commit 0929bf9

Please sign in to comment.