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


Python IMAP.set_acl方法代码示例

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


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

示例1: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例2: check_message_received

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例3: check_resource_calendar_event

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例4: check_user_imap_object

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例5: update_calendar_event

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例6: create_task_assignment

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例7: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [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

示例8: purge_mailbox

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
    def purge_mailbox(self, mailbox):
        imap = IMAP()
        imap.connect()
        imap.set_acl(mailbox, "cyrus-admin", "lrwcdest")
        imap.imap.m.select(imap.folder_quote(mailbox))

        typ, data = imap.imap.m.search(None, 'ALL')
        for num in data[0].split():
            imap.imap.m.store(num, '+FLAGS', '\\Deleted')

        imap.imap.m.expunge()
        imap.disconnect()
开发者ID:tpokorra,项目名称:pykolab,代码行数:14,代码来源:test_006_resource_performance.py

示例9: execute

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

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

    except:
        log.error(_("Specify a folder"))
        sys.exit(1)

    imap = IMAP()
    imap.connect()

    _folder = imap.lm(imap_utf7.encode(folder))

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

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

    imap.select(imap_utf7.encode(folder))

    if conf.list_deleted:
        typ, data = imap.search(None, 'ALL')
    else:
        typ, data = imap.search(None, '(ALL UNDELETED)')

    num_messages = len(data[0].split())

    for num in data[0].split():
        typ, flags = imap.fetch(num, 'FLAGS')
        flags = flags[0].split()
        if len(flags) >= 3:
            # Any flags are set
            if flags[2] == '(\\Deleted))':
                print num, '\Deleted'
            elif flags[2] == '(\\Deleted':
                print num, '\Deleted'
            elif '\\Deleted' in flags[3:]:
                print num, '\Deleted'
            elif '\\Deleted))' in flags[3:]:
                print num, '\Deleted'
            else:
                print num
        else:
            print num

    imap.set_acl(folder, 'cyrus-admin', '')
开发者ID:tpokorra,项目名称:pykolab,代码行数:53,代码来源:cmd_list_messages.py

示例10: create_calendar_event

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
    def create_calendar_event(self, start=None, summary="test", sequence=0, user=None, attendees=None, folder=None):
        if start is None:
            start = datetime.datetime.now(pytz.timezone("Europe/Berlin"))
        if user is None:
            user = self.john
        if attendees is None:
            attendees = [self.jane]
        if folder is None:
            folder = user['kolabcalendarfolder']

        end = start + datetime.timedelta(hours=4)

        event = pykolab.xml.Event()
        event.set_start(start)
        event.set_end(end)
        event.set_organizer(user['mail'], user['displayname'])

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

        event.set_summary(summary)
        event.set_sequence(sequence)

        # create event with attachment
        vattach = event.get_attachments()
        attachment = kolabformat.Attachment()
        attachment.setLabel('attach.txt')
        attachment.setData('This is a text attachment', 'text/plain')
        vattach.append(attachment)
        event.event.setAttachments(vattach)

        imap = IMAP()
        imap.connect()

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

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

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

示例11: test_002_send_forwarded_email

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
    def test_002_send_forwarded_email(self):
        import smtplib
        from email.MIMEMultipart import MIMEMultipart
        from email.MIMEBase import MIMEBase
        from email.MIMEText import MIMEText
        from email.Utils import COMMASPACE, formatdate
        from email import Encoders

        smtp = smtplib.SMTP('localhost', 10026)
        subject = "%s" % (time.time())
        body = "This is a test message"
        msg = MIMEMultipart()
        msg['From'] = '"Doe, Jane" <[email protected]>'
        msg['To'] = '"Doe, John" <[email protected]>'
        msg['Subject'] = subject
        msg['Date'] = formatdate(localtime=True)
        msg.attach(MIMEText(body))

        send_to = '[email protected]'
        send_from = '[email protected]'

        smtp.sendmail(send_from, send_to, msg.as_string())

        imap = IMAP()
        imap.connect()
        imap.set_acl("user/[email protected]", "cyrus-admin", "lrs")
        imap.imap.m.select("user/[email protected]")

        found = False
        max_tries = 20

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

            typ, data = imap.imap.m.search(None, 'ALL')
            for num in data[0].split():
                typ, msg = imap.imap.m.fetch(num, '(RFC822)')
                _msg = message_from_string(msg[0][1])
                if _msg['Subject'] == subject:
                    found = True

            time.sleep(1)

        if not found:
            raise Exception
开发者ID:tpokorra,项目名称:pykolab,代码行数:47,代码来源:test_001_user_add.py

示例12: check_message_delivered

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
    def check_message_delivered(self, subject):
        imap = IMAP()
        imap.connect()
        imap.set_acl("user/[email protected]", "cyrus-admin", "lrs")
        imap.imap.m.select("user/[email protected]")

        found = False
        max_tries = 20

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

            typ, data = imap.imap.m.search(None, 'ALL')
            for num in data[0].split():
                typ, msg = imap.imap.m.fetch(num, '(RFC822)')
                _msg = message_from_string(msg[0][1])
                if _msg['Subject'] == subject:
                    found = True

            time.sleep(1)

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

示例13: description

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
def description():
    return """Delete an ACL entry for a folder."""

def execute(*args, **kw):
    try:
        folder = conf.cli_args.pop(0)
        try:
            identifier = conf.cli_args.pop(0)
        except IndexError, errmsg:
            identifier = utils.ask_question(_("ACI Subject"))

    except IndexError, errmsg:
        folder = utils.ask_question(_("Folder name"))
        quota = utils.ask_question(_("ACI Subject"))

    if len(folder.split('@')) > 1:
        domain = folder.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain)

    if not imap.has_folder(folder):
        print >> sys.stderr, _("No such folder %r") % (folder)

    else:
        folders = imap.lm(folder)
        for folder in folders:
            imap.set_acl(folder, identifier, '')
开发者ID:detrout,项目名称:pykolab,代码行数:32,代码来源:cmd_delete_mailbox_acl.py

示例14: len

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
            identifier = conf.cli_args.pop(0)
            try:
                acl = conf.cli_args.pop(0)
            except IndexError, errmsg:
                acl = utils.ask_question(_("ACI Permissions"))

        except IndexError, errmsg:
            identifier = utils.ask_question(_("ACI Subject"))
            acl = utils.ask_question(_("ACI Permissions"))

    except IndexError, errmsg:
        folder = utils.ask_question(_("Folder name"))
        identifier = utils.ask_question(_("ACI Subject"))
        acl = utils.ask_question(_("ACI Permissions"))

    if len(folder.split('@')) > 1:
        domain = folder.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain)

    if not imap.has_folder(folder):
        print >> sys.stderr, _("No such folder %r") % (folder)

    else:
        folders = imap.lm(folder)
        for folder in folders:
            imap.set_acl(folder, identifier, acl)
开发者ID:detrout,项目名称:pykolab,代码行数:32,代码来源:cmd_set_mailbox_acl.py

示例15: calendar

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import set_acl [as 别名]
def calendar(user):
    return imap_utf7.encode( "user/{username}/[email protected]".format(username=user))

def appendEvent(user, event):
    """event must be a ical object (python icalendar Event)"""
    e = event_from_ical(event) # construct a kolab object
    folder = calendar(user)
    imap.append(folder, None, None, e.to_message().as_string())

if __name__ == '__main__':
    conf = pykolab.getConf()
    conf.finalize_conf()

    imap = IMAP()
    imap.connect()

    user = "john.doe"

    start = datetime(2015, 1, 1, 0, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
    end = datetime(2015, 1, 1, 10, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
    event = ical.createEvent(start, end)

    # Admin normally has no right to do anything with the mailbox
    # so first add the right to append message (i) after adding the message
    # remove the right again
    imap.set_acl(calendar(user), 'cyrus-admin', 'lrsi')
    try:
        appendEvent(user, event)
    finally:
        imap.set_acl(calendar(user), 'cyrus-admin', '')
开发者ID:cmollekopf,项目名称:docker,代码行数:32,代码来源:populate_calendar.py


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