From 49860fe1ce4357689033e526bd506c266ce3cc16 Mon Sep 17 00:00:00 2001 From: scrat Date: Sat, 12 Apr 2008 16:29:12 +0000 Subject: [PATCH] changed structure in cybertools/agent/crawl/outlook.py according to loops/agent/crawl/filesystem.py adaptations and changes in winapi.py (Added Mail class and Items in Outlook Folder) placed comments in proper lines of winapi what next has to be found out about Outlook Mail Objects Doctests are ok, but iterating over loadMailsFromFolder in outlook.py has a problem with NoneType and therefor does not work yet git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2522 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/crawl/outlook.py | 10 ++++++++-- agent/crawl/outlook.txt | 3 +++ agent/testing/winapi.py | 7 ++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/agent/crawl/outlook.py b/agent/crawl/outlook.py index 2bdc164..6669a1e 100644 --- a/agent/crawl/outlook.py +++ b/agent/crawl/outlook.py @@ -41,6 +41,7 @@ from cybertools.agent.crawl.mail import MailCrawler from cybertools.agent.crawl.mail import MailResource from cybertools.agent.components import agents from cybertools.agent.system.windows import api +from cybertools.agent.util.task import coiterate # some constants COMMASPACE = ', ' @@ -53,16 +54,20 @@ class OutlookCrawler(MailCrawler): pattern = "" def collect(self, filter=None): + self.collected = [] self.d = defer.Deferred() self.oOutlookApp = None if self.findOutlook(): self.fetchCriteria() - self.d.addCallback(self.crawlFolders) + coiterate(self.crawlFolders()).addCallback(self.finished) else: pass #self.d.addErrback([]) return self.d + def finished(self, result): + self.d.callback(self.result) + def fetchCriteria(self): criteria = self.params self.keys = criteria.get('keys') @@ -91,7 +96,6 @@ class OutlookCrawler(MailCrawler): # get specified MAPI-subfolder object and load its emails if self.pattern.match(getattr(lInboxSubfolders.Item(of + 1), 'Name')): self.loadMailsFromFolder(lInboxSubfolders.Item(of + 1)) - return self.result def loadMailsFromFolder(self, folder): # get items of the folder @@ -111,6 +115,8 @@ class OutlookCrawler(MailCrawler): msg = self.createEmailMime(record) # Create a resource and append it to the result list self.createResource(msg, folder, "Microsoft Office Outlook") + #return self.result + yield None def login(self): pass diff --git a/agent/crawl/outlook.txt b/agent/crawl/outlook.txt index aa6f7d3..f6d7e7c 100644 --- a/agent/crawl/outlook.txt +++ b/agent/crawl/outlook.txt @@ -43,3 +43,6 @@ the twisted reactor first. >>> from cybertools.agent.tests import tester >>> tester.iterate() Outlook.Application retrieved + Namespace MAPI retrieved + retrieving Outlook default folder + collecting Mails from folder diff --git a/agent/testing/winapi.py b/agent/testing/winapi.py index bc47d7a..bc40268 100644 --- a/agent/testing/winapi.py +++ b/agent/testing/winapi.py @@ -46,9 +46,10 @@ class OutlookFolder(object): Folders = None def __init__(self): - Items[0] = Mail() - Items[1] = Mail() - pass + print "collecting Mails from folder" + self.Items[0] = Mail() + self.Items[1] = Mail() + self.Items[2] = Mail() class OutlookNamespace(object):