From 104d0ac88fb5990563cfa66adde921ee733ce52a Mon Sep 17 00:00:00 2001 From: scrat Date: Wed, 9 Apr 2008 13:46:38 +0000 Subject: [PATCH] Added some missing api. references in outlook.py Added some Dummy Implementations for Outlook Crawler in /testing/winapi.py Changed outlook.txt accordingly git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2510 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/crawl/base.py | 6 +++++ agent/crawl/outlook.py | 18 +++++++++----- agent/crawl/outlook.txt | 1 + agent/testing/winapi.py | 54 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/agent/crawl/base.py b/agent/crawl/base.py index f0e75b6..b9143aa 100644 --- a/agent/crawl/base.py +++ b/agent/crawl/base.py @@ -35,6 +35,12 @@ from twisted.internet.defer import succeed class Crawler(QueueableAgent): implements(ICrawler) + + params = {} + + def __init__(self, master, params={}): + super(Crawler, self).__init__(master) + self.params = params def process(self): return self.collect() diff --git a/agent/crawl/outlook.py b/agent/crawl/outlook.py index edca280..1027347 100644 --- a/agent/crawl/outlook.py +++ b/agent/crawl/outlook.py @@ -23,12 +23,18 @@ $Id$ """ import re +from email import MIMEMultipart from zope.interface import implements from twisted.internet import defer #import win32com.client #import ctypes #import win32api, win32process, win32con +#The watsup import is needed as soon as we start handling the Outlook Pop-Up +#again +#This should also be integrated within the wrapper-api for doctests +#from watsup.winGuiAuto import findTopWindow, findControl, findControls, clickButton, \ +# getComboboxItems, selectComboboxItem, setCheckBox from cybertools.agent.base.agent import Agent, Master from cybertools.agent.crawl.mail import MailCrawler @@ -63,13 +69,13 @@ class OutlookCrawler(MailCrawler): self.inbox = criteria.get('inbox') #boolean self.subfolders = criteria.get('subfolders') #boolean self.pattern = criteria.get('pattern') - if self.pattern != '': + if self.pattern != '' and self.pattern != None: self.pattern = re.compile(criteria.get('pattern') or '.*') def crawlFolders(self): onMAPI = self.oOutlookApp.GetNamespace("MAPI") ofInbox = \ - onMAPI.GetDefaultFolder(win32com.client.constants.olFolderInbox) + onMAPI.GetDefaultFolder(api.client.constants.olFolderInbox) # fetch mails from inbox if self.inbox: self.loadMailsFromFolder(ofInbox) @@ -92,7 +98,7 @@ class OutlookCrawler(MailCrawler): folderItems = getattr(folder, 'Items') for item in range(len(folderItems)): mail = folderItems.Item(item+1) - if mail.Class == win32com.client.constants.olMail: + if mail.Class == api.win32com.client.constants.olMail: if self.keys is None: self.keys = [] for key in mail._prop_map_get_: @@ -116,17 +122,17 @@ class OutlookCrawler(MailCrawler): """ hwnd = None while True: - hwnd = ctypes.windll.user32.FindWindowExA(None, hwnd, None, None) + hwnd = api.ctypes.windll.user32.FindWindowExA(None, hwnd, None, None) if hwnd == None: break else: val = u"\0" * 1024 - ctypes.windll.user32.GetWindowTextW(hwnd, val, len(val)) + api.ctypes.windll.user32.GetWindowTextW(hwnd, val, len(val)) val = val.replace(u"\000", u"") if val and repr(val) == "u'Microsoft Office Outlook'": print repr(val) # get the Main Control - form = findTopWindow(wantedText='Microsoft Office Outlook') + form = api.findTopWindow(wantedText='Microsoft Office Outlook') controls = findControls(form) # get the check box checkBox = findControl(form, wantedText='Zugriff') diff --git a/agent/crawl/outlook.txt b/agent/crawl/outlook.txt index d2da0c1..aa6f7d3 100644 --- a/agent/crawl/outlook.txt +++ b/agent/crawl/outlook.txt @@ -42,3 +42,4 @@ the twisted reactor first. >>> from cybertools.agent.tests import tester >>> tester.iterate() + Outlook.Application retrieved diff --git a/agent/testing/winapi.py b/agent/testing/winapi.py index 5b91ab8..5fb13de 100644 --- a/agent/testing/winapi.py +++ b/agent/testing/winapi.py @@ -23,3 +23,57 @@ $Id$ """ client = ctypes = win32api = win32process = win32con = None + + +class OutlookFolder(object): + + Items = {'mail1': "eMail 1", 'mail2': "eMail2"} + + def __init__(self): + pass + + +class OutlookNamespace(object): + + def __init__(self): + pass + + def GetDefaultFolder(self, message=""): + print "retrieving Outlook default folder" + folder = OutlookFolder() + return folder + + +class OutlookApp(object): + + def __init__(self): + pass + + def GetNamespace(self, message=""): + print "Namespace " + message + " retrieved" + return + + +class Message(object): + + olFolderInbox = None + + def __init__(self): + pass + + def EnsureDispatch(self, message=""): + print message + " retrieved" + + +class client(object): + + gencache = Message() + constants = Message() + + def __init__(self): + pass + +class ctypes(object): + + def __init__(self): + pass \ No newline at end of file