当前位置: 首页>>代码示例>>Python>>正文


Python IMAP.connect方法代码示例

本文整理汇总了Python中pykolab.imap.IMAP.connect方法的典型用法代码示例。如果您正苦于以下问题:Python IMAP.connect方法的具体用法?Python IMAP.connect怎么用?Python IMAP.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykolab.imap.IMAP的用法示例。


在下文中一共展示了IMAP.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_calendar_event

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def update_calendar_event(self, uid, start=None, summary=None, sequence=0, user=None):
        if user is None:
            user = self.john

        event = self.check_user_calendar_event(user['kolabcalendarfolder'], uid)
        if event:
            if start is not None:
                event.set_start(start)
            if summary is not None:
                event.set_summary(summary)
            if sequence is not None:
                event.set_sequence(sequence)

            imap = IMAP()
            imap.connect()

            mailbox = imap.folder_quote(user['kolabcalendarfolder'])
            imap.set_acl(mailbox, "cyrus-admin", "lrswipkxtecda")
            imap.imap.m.select(mailbox)

            return imap.imap.m.append(
                mailbox,
                None,
                None,
                event.to_message().as_string()
            )

        return False
开发者ID:tpokorra,项目名称:pykolab,代码行数:30,代码来源:test_007_invitationpolicy.py

示例2: check_user_imap_object

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def check_user_imap_object(self, mailbox, uid=None, type='event'):
        imap = IMAP()
        imap.connect()

        mailbox = imap.folder_quote(mailbox)
        imap.set_acl(mailbox, "cyrus-admin", "lrs")
        imap.imap.m.select(mailbox)

        found = None
        retries = 15

        while not found and retries > 0:
            retries -= 1

            typ, data = imap.imap.m.search(None, '(UNDELETED HEADER SUBJECT "%s")' % (uid) if uid else '(UNDELETED HEADER X-Kolab-Type "application/x-vnd.kolab.' + type + '")')
            for num in data[0].split():
                typ, data = imap.imap.m.fetch(num, '(RFC822)')
                object_message = message_from_string(data[0][1])

                # return matching UID or first event found
                if uid and object_message['subject'] != uid:
                    continue

                if type == 'task':
                    found = todo_from_message(object_message)
                else:
                    found = event_from_message(object_message)

                if found:
                    break

            time.sleep(1)

        return found
开发者ID:tpokorra,项目名称:pykolab,代码行数:36,代码来源:test_007_invitationpolicy.py

示例3: create_task_assignment

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def create_task_assignment(self, due=None, summary="test", sequence=0, user=None, attendees=None):
        if due is None:
            due = datetime.datetime.now(pytz.timezone("Europe/Berlin")) + datetime.timedelta(days=2)
        if user is None:
            user = self.john
        if attendees is None:
            attendees = [self.jane]

        todo = pykolab.xml.Todo()
        todo.set_due(due)
        todo.set_organizer(user['mail'], user['displayname'])

        for attendee in attendees:
            todo.add_attendee(attendee['mail'], attendee['displayname'], role="REQ-PARTICIPANT", participant_status="NEEDS-ACTION", rsvp=True)

        todo.set_summary(summary)
        todo.set_sequence(sequence)

        imap = IMAP()
        imap.connect()

        mailbox = imap.folder_quote(user['kolabtasksfolder'])
        imap.set_acl(mailbox, "cyrus-admin", "lrswipkxtecda")
        imap.imap.m.select(mailbox)

        result = imap.imap.m.append(
            mailbox,
            None,
            None,
            todo.to_message().as_string()
        )

        return todo.get_uid()
开发者ID:tpokorra,项目名称:pykolab,代码行数:35,代码来源:test_007_invitationpolicy.py

示例4: check_resource_calendar_event

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def check_resource_calendar_event(self, mailbox, uid=None):
        imap = IMAP()
        imap.connect()

        imap.set_acl(mailbox, "cyrus-admin", "lrs")
        imap.imap.m.select(imap.folder_quote(mailbox))

        found = None
        retries = 10

        while not found and retries > 0:
            retries -= 1

            typ, data = imap.imap.m.search(None, '(UNDELETED HEADER SUBJECT "%s")' % (uid) if uid else '(UNDELETED HEADER X-Kolab-Type "application/x-vnd.kolab.event")')
            for num in data[0].split():
                typ, data = imap.imap.m.fetch(num, '(RFC822)')
                event_message = message_from_string(data[0][1])

                # return matching UID or first event found
                if uid and event_message['subject'] != uid:
                    continue

                found = event_from_message(event_message)
                if found:
                    break

            time.sleep(1)

        imap.disconnect()

        return found
开发者ID:tpokorra,项目名称:pykolab,代码行数:33,代码来源:test_005_resource_invitation.py

示例5: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
def execute(*args, **kw):
    """
        List mailboxes
    """

    try:
        aci_subject = conf.cli_args.pop(0)
    except:
        aci_subject = None

    imap = IMAP()
    imap.connect()

    folders = imap.lm()

    for folder in folders:
        acls = imap.list_acls(folder)

        if not aci_subject == None:
            if aci_subject in acls.keys():
                log.debug(_("Deleting ACL %s for subject %s on folder %s") % (
                        acls[aci_subject],
                        aci_subject,
                        folder
                    ), level=8)

                imap.set_acl(folder, aci_subject, '')

        #else:
            #for _aci_subject in acls.keys():
                # connect to auth(!)
                # find recipient result_attr=aci_subject
                # if no entry, expire acl
开发者ID:tpokorra,项目名称:pykolab,代码行数:35,代码来源:cmd_acl_cleanup.py

示例6: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
def execute(*args, **kw):
    """
        List deleted mailboxes
    """

    try:
        domain = conf.cli_args.pop(0)
    except:
        domain = utils.ask_question(_("Domain"))

    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for primary,secondaries in domains:
        if not domain == primary and not domain in secondaries:
            continue

        folders.extend(imap.lm("user/%%@%s" % (primary)))
        for secondary in secondaries:
            folders.extend(imap.lm("user/%%@%s" % (secondary)))

    print "Deleted folders:"

    for folder in folders:
        if not conf.raw:
            print imap_utf7.decode(folder)
        else:
            print folder
开发者ID:tpokorra,项目名称:pykolab,代码行数:36,代码来源:cmd_list_domain_mailboxes.py

示例7: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
def execute(*args, **kw):
    """
        Delete mailbox
    """

    if len(conf.cli_args) < 1:
        print >> sys.stderr, _("No mailbox specified")
        sys.exit(1)

    imap = IMAP()

    imap.connect()

    delete_folders = []
    while len(conf.cli_args) > 0:
        folder = conf.cli_args.pop(0)
        folders = imap.list_folders(folder)

        if len(folders) < 1:
            print >> sys.stderr, _("No such folder(s): %s") % (folder)

        delete_folders.extend(folders)

    if len(delete_folders) == 0:
        print >> sys.stderr, _("No folders to delete.")
        sys.exit(1)

    for delete_folder in delete_folders:
        try:
            imap.delete_mailfolder(delete_folder)
        except Exception, errmsg:
            log.error(_("Could not delete mailbox '%s'") % (delete_folder))
开发者ID:tpokorra,项目名称:pykolab,代码行数:34,代码来源:cmd_delete_mailbox.py

示例8: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
def execute(*args, **kw):
    """
        Delete a message from a mail folder
    """

    try:
        folder = conf.cli_args.pop(0)

        try:
            uid = conf.cli_args.pop(0)
        except:
            log.error(_("Specify a UID"))
            sys.exit(1)
    except:
        log.error(_("Specify a folder"))
        sys.exit(1)

    imap = IMAP()
    imap.connect()

    _folder = imap.lm(folder)

    if _folder == None or _folder == []:
        log.error(_("No such folder"))
        sys.exit(1)

    imap.set_acl(folder, 'cyrus-admin', 'lrswt')

    imap.select(folder)

    imap.store(uid, '+FLAGS', '\\Deleted')
开发者ID:tpokorra,项目名称:pykolab,代码行数:33,代码来源:cmd_delete_message.py

示例9: test_005_user_folders_metadata_set

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def test_005_user_folders_metadata_set(self):
        imap = IMAP()
        imap.connect()

        ac_folders = conf.get_raw('kolab', 'autocreate_folders')
        exec("ac_folders = %s" % (ac_folders))

        folders = []
        folders.extend(imap.lm('user/%(local)[email protected]%(domain)s' % (self.user)))
        folders.extend(imap.lm('user/%(local)s/*@%(domain)s' % (self.user)))

        for folder in folders:
            metadata = imap.get_metadata(folder)
            print metadata

            folder_name = '/'.join(folder.split('/')[2:]).split('@')[0]
            if ac_folders.has_key(folder_name):
                if ac_folders[folder_name].has_key('annotations'):
                    for _annotation in ac_folders[folder_name]['annotations'].keys():
                        if _annotation.startswith('/private'):
                            continue

                        _annotation_value = ac_folders[folder_name]['annotations'][_annotation]
                        self.assertTrue(metadata[metadata.keys().pop()].has_key(_annotation))
                        self.assertEqual(_annotation_value, metadata[metadata.keys().pop()][_annotation])
开发者ID:tpokorra,项目名称:pykolab,代码行数:27,代码来源:test_001_user_sync.py

示例10: check_message_received

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def check_message_received(self, subject, from_addr=None, mailbox=None):
        if mailbox is None:
            mailbox = self.john['mailbox']

        imap = IMAP()
        imap.connect()
        imap.set_acl(mailbox, "cyrus-admin", "lrs")
        imap.imap.m.select(mailbox)

        found = None
        retries = 10

        while not found and retries > 0:
            retries -= 1

            typ, data = imap.imap.m.search(None, '(UNDELETED HEADER FROM "%s")' % (from_addr) if from_addr else 'UNDELETED')
            for num in data[0].split():
                typ, msg = imap.imap.m.fetch(num, '(RFC822)')
                message = message_from_string(msg[0][1])
                if message['Subject'] == subject:
                    found = message
                    break

            time.sleep(1)

        imap.disconnect()

        return found
开发者ID:tpokorra,项目名称:pykolab,代码行数:30,代码来源:test_005_resource_invitation.py

示例11: teardown_class

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def teardown_class(self):
        time.sleep(2)

        res_attr = conf.get('cyrus-sasl', 'result_attribute')

        exec("ac_folders = %s" % (conf.get_raw(conf.get('kolab', 'primary_domain'), 'autocreate_folders')))
        expected_number_of_folders = len(ac_folders.keys()) + 1

        users = []

        result = wap_client.users_list()
        for user in result['list'].keys():
            user_info = wap_client.user_info(user)
            users.append(user_info)
            result = wap_client.user_delete({'user': user})

        imap = IMAP()
        imap.connect()

        for user in users:
            if len(user[res_attr].split('@')) > 1:
                localpart = user[res_attr].split('@')[0]
                domain = user[res_attr].split('@')[1]

            folders = []
            folders.extend(imap.lm('user/%s' % (user[res_attr])))
            folders.extend(imap.lm('user/%s/*@%s' % (localpart,domain)))
开发者ID:detrout,项目名称:pykolab,代码行数:29,代码来源:test_002_user_add.py

示例12: connect

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def connect(self, uri):
        """
            Dummy connect function that checks if the server that we want to
            connect to is actually the server we are connected to.

            Uses pykolab.imap.IMAP.connect() in the background.
        """
        port = None

        result = urlparse(uri)

        if hasattr(result, 'hostname'):
            scheme = result.scheme
            hostname = result.hostname
            port = result.port
        else:
            scheme = uri.split(':')[0]
            (hostname, port) = uri.split('/')[2].split(':')

        if not port:
            if scheme == 'imap':
                port = 143
            else:
                port = 993

        if hostname == self.server:
            return

        imap = IMAP()
        imap.connect(uri=uri)

        if not self.SEP == self.separator:
            self.separator = self.SEP
开发者ID:tpokorra,项目名称:pykolab,代码行数:35,代码来源:cyrus.py

示例13: test_001_inbox_created

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
    def test_001_inbox_created(self):
        time.sleep(2)
        imap = IMAP()
        imap.connect()

        folders = imap.lm('user/%(local)[email protected]%(domain)s' % (self.user))
        self.assertEqual(len(folders), 1)
开发者ID:detrout,项目名称:pykolab,代码行数:9,代码来源:test_002_user_add.py

示例14: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
def execute(*args, **kw):
    """
        List mailboxes
    """

    searches = []

    # See if conf.cli_args components make sense.
    for arg in conf.cli_args:
        if arg == '*':
            searches.append(arg)
        if arg.startswith('user'):
            searches.append(arg)
        if arg.startswith('shared'):
            searches.append(arg)
        if arg.startswith('DELETED'):
            searches.append(arg)
        if arg.startswith('news'):
            searches.append(arg)

    if len(searches) == 0:
        searches = [ '' ]

    imap = IMAP()
    imap.connect()

    folders = []

    for search in searches:
        log.debug(_("Appending folder search for %r") % (search), level=8)
        folders.extend(imap.lm(search))

    for folder in folders:
        print folder
开发者ID:detrout,项目名称:pykolab,代码行数:36,代码来源:cmd_list_mailboxes.py

示例15: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import connect [as 别名]
def execute(*args, **kw):
    """
        List deleted mailboxes
    """
    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for domain in list(set(domains.keys())):
        folders.extend(imap.lm("DELETED/*@%s" % (domain)))

    folders.extend(imap.lm("DELETED/*"))

    print "Deleted folders:"

    for folder in folders:
        mbox_parts = imap.parse_mailfolder(folder)

        if not conf.raw:
            print "%s (Deleted at %s)" % (imap_utf7.decode(folder).encode('utf-8'), datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
        else:
            print "%s (Deleted at %s)" % (folder, datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
开发者ID:tpokorra,项目名称:pykolab,代码行数:29,代码来源:cmd_list_deleted_mailboxes.py


注:本文中的pykolab.imap.IMAP.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。