work in progress: outlook crawler: make dummy implementation work
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2528 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
1011f4b2eb
commit
1a0084e46f
3 changed files with 56 additions and 32 deletions
|
@ -54,17 +54,21 @@ class OutlookCrawler(MailCrawler):
|
|||
pattern = ""
|
||||
|
||||
def collect(self, filter=None):
|
||||
self.collected = []
|
||||
self.result = []
|
||||
self.d = defer.Deferred()
|
||||
self.oOutlookApp = None
|
||||
if self.findOutlook():
|
||||
self.fetchCriteria()
|
||||
coiterate(self.crawlFolders()).addCallback(self.finished)
|
||||
coiterate(self.crawlFolders()).addCallback(self.finished).addErrback(self.error)
|
||||
else:
|
||||
pass
|
||||
#self.d.addErrback([])
|
||||
return self.d
|
||||
|
||||
def error(self, reason):
|
||||
print '***** error',
|
||||
print reason
|
||||
|
||||
def finished(self, result):
|
||||
self.d.callback(self.result)
|
||||
|
||||
|
@ -83,19 +87,22 @@ class OutlookCrawler(MailCrawler):
|
|||
onMAPI.GetDefaultFolder(api.client.constants.olFolderInbox)
|
||||
# fetch mails from inbox
|
||||
if self.inbox:
|
||||
self.loadMailsFromFolder(ofInbox)
|
||||
for m in self.loadMailsFromFolder(ofInbox):
|
||||
yield None
|
||||
# fetch mails of inbox subfolders
|
||||
if self.subfolders and self.pattern is None:
|
||||
lInboxSubfolders = getattr(ofInbox, 'Folders')
|
||||
for of in range(lInboxSubfolders.__len__()):
|
||||
# get a MAPI-subfolder object and load its emails
|
||||
yield self.loadMailsFromFolder(lInboxSubfolders.Item(of + 1))
|
||||
for m in self.loadMailsFromFolder(lInboxSubfolders.Item(of + 1)):
|
||||
yield None
|
||||
elif self.subfolders and self.pattern:
|
||||
lInboxSubfolders = getattr(ofInbox, 'Folders')
|
||||
for of in range(lInboxSubfolders.__len__()):
|
||||
# get specified MAPI-subfolder object and load its emails
|
||||
if self.pattern.match(getattr(lInboxSubfolders.Item(of + 1), 'Name')):
|
||||
yield self.loadMailsFromFolder(lInboxSubfolders.Item(of + 1))
|
||||
for m in self.loadMailsFromFolder(lInboxSubfolders.Item(of + 1)):
|
||||
yield None
|
||||
|
||||
def loadMailsFromFolder(self, folder):
|
||||
# get items of the folder
|
||||
|
@ -164,7 +171,7 @@ class OutlookCrawler(MailCrawler):
|
|||
|
||||
def createEmailMime(self, emails):
|
||||
# Create the container (outer) email message.
|
||||
msg = MIMEMultipart()
|
||||
msg = MIMEMultipart.MIMEMultipart()
|
||||
msg['Subject'] = emails['Subject'].encode('utf-8')
|
||||
if emails.has_key('SenderEmailAddress'):
|
||||
sender = str(emails['SenderEmailAddress'].encode('utf-8'))
|
||||
|
|
|
@ -35,7 +35,7 @@ dlls".
|
|||
|
||||
In the next step we request the start of a job, again via the controller.
|
||||
|
||||
>>> controller.enterJob('sample', 'sample02')
|
||||
>>> controller.enterJob('sample', 'sample02', params=dict(inbox=True))
|
||||
|
||||
The job is not executed immediately - we have to hand over control to
|
||||
the twisted reactor first.
|
||||
|
@ -46,4 +46,4 @@ the twisted reactor first.
|
|||
Namespace MAPI retrieved
|
||||
retrieving Outlook default folder
|
||||
collecting Mails from folder
|
||||
Job 00001 completed; result: [];
|
||||
Job 00001 completed; result: [...];
|
||||
|
|
|
@ -27,29 +27,46 @@ client = ctypes = win32api = win32process = win32con = None
|
|||
class Mail(object):
|
||||
|
||||
#this is just a guess what a Outlook Mail Object Probably returns
|
||||
Class = None
|
||||
#Class = client.constants.olMail
|
||||
|
||||
def __init__(self):
|
||||
Class = self.__class__
|
||||
self.Class = client.constants.olMail
|
||||
self.Subject = 'dummy'
|
||||
self.SenderName = 'dummy'
|
||||
self.To = 'dummy'
|
||||
self.Body = 'dummy'
|
||||
|
||||
@property
|
||||
def _prop_map_get_(self):
|
||||
#here it is necessary of what attributes (called keys in outlok.py)
|
||||
#an Outlook Mail typically has
|
||||
# should return a tuple ()
|
||||
pass
|
||||
return ('Subject', 'SenderName', 'To', 'Body')
|
||||
|
||||
|
||||
class Items(object):
|
||||
|
||||
def __init__(self):
|
||||
self.data = {}
|
||||
self.data[0] = Mail()
|
||||
self.data[1] = Mail()
|
||||
self.data[2] = Mail()
|
||||
|
||||
def Item(self, idx):
|
||||
return self.data[idx-1]
|
||||
|
||||
def __len__(self):
|
||||
return len(self.data)
|
||||
|
||||
|
||||
class OutlookFolder(object):
|
||||
|
||||
Items = {}
|
||||
# Folders defines in Outlook the sub folders under the "Main" Folder
|
||||
Folders = None
|
||||
|
||||
def __init__(self):
|
||||
print "collecting Mails from folder"
|
||||
self.Items[0] = Mail()
|
||||
self.Items[1] = Mail()
|
||||
self.Items[2] = Mail()
|
||||
self.Items = Items()
|
||||
|
||||
|
||||
class OutlookNamespace(object):
|
||||
|
@ -81,7 +98,7 @@ class Message(object):
|
|||
# to find out, what class is expected. Meaning what type of object has
|
||||
# to be faked and what attributes it has. see outlook.py
|
||||
# loadMailsfromFolder
|
||||
olMail = Mail()
|
||||
olMail = Mail
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue