當前位置: 首頁>>代碼示例>>Python>>正文


Python Auth.find_resource方法代碼示例

本文整理匯總了Python中pykolab.auth.Auth.find_resource方法的典型用法代碼示例。如果您正苦於以下問題:Python Auth.find_resource方法的具體用法?Python Auth.find_resource怎麽用?Python Auth.find_resource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pykolab.auth.Auth的用法示例。


在下文中一共展示了Auth.find_resource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_001_resource_created

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import find_resource [as 別名]
    def test_001_resource_created(self):
        auth = Auth()
        auth.connect()
        resource = auth.find_resource(self.audi['mail'])
        self.assertEqual(resource, self.audi['dn'])

        collection = auth.find_resource(self.cars['mail'])
        self.assertEqual(collection, self.cars['dn'])
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:10,代碼來源:test_008_resource_add.py

示例2: resource_record_from_email_address

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import find_resource [as 別名]
def resource_record_from_email_address(email_address):
    auth = Auth()
    auth.connect()
    resource_records = []

    log.debug(
            _("Checking if email address %r belongs to a resource (collection)") % (
                    email_address
                ),
            level=8
        )

    resource_records = auth.find_resource(email_address)

    if isinstance(resource_records, list):
        if len(resource_records) == 0:
            log.debug(
                    _("No resource (collection) records found for %r") % (
                            email_address
                        ),
                    level=9
                )

        else:
            log.debug(
                    _("Resource record(s): %r") % (resource_records),
                    level=8
                )

    elif isinstance(resource_records, basestring):
        log.debug(
                _("Resource record: %r") % (resource_records),
                level=8
            )

        resource_records = [ resource_records ]

    return resource_records
開發者ID:detrout,項目名稱:pykolab,代碼行數:40,代碼來源:module_resources.py

示例3: resource_record_from_email_address

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import find_resource [as 別名]
def resource_record_from_email_address(email_address):
    """
        Resolves the given email address to a resource entity
    """
    global auth

    if not auth:
        auth = Auth()
        auth.connect()

    resource_records = []

    local_domains = auth.list_domains()

    if not local_domains == None:
        local_domains = list(set(local_domains.keys()))

    if not email_address.split('@')[1] in local_domains:
        return []

    log.debug(
        _("Checking if email address %r belongs to a resource (collection)") % (email_address),
        level=8
    )

    resource_records = auth.find_resource(email_address)

    if isinstance(resource_records, list):
        if len(resource_records) > 0:
            log.debug(_("Resource record(s): %r") % (resource_records), level=8)
        else:
            log.debug(_("No resource (collection) records found for %r") % (email_address), level=9)

    elif isinstance(resource_records, basestring):
        resource_records = [ resource_records ]
        log.debug(_("Resource record: %r") % (resource_records), level=8)

    return resource_records
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:40,代碼來源:module_resources.py

示例4: heartbeat

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import find_resource [as 別名]
def heartbeat(lastrun):
    global imap

    # run archival job every hour only
    now = int(time.time())
    if lastrun == 0 or now - heartbeat._lastrun < 3600:
        return

    log.debug(_("module_resources.heartbeat(%d)") % (heartbeat._lastrun), level=8)

    # get a list of resource records from LDAP
    auth = Auth()
    auth.connect()

    resource_dns = auth.find_resource('*')

    # filter by resource_base_dn
    resource_base_dn = conf.get('ldap', 'resource_base_dn', None)
    if resource_base_dn is not None:
        resource_dns = [dn for dn in resource_dns if resource_base_dn in dn]

    if len(resource_dns) > 0:
        imap = IMAP()
        imap.connect()

        for resource_dn in resource_dns:
            resource_attrs = auth.get_entry_attributes(None, resource_dn, ['kolabtargetfolder'])
            if resource_attrs.has_key('kolabtargetfolder'):
                try:
                    expunge_resource_calendar(resource_attrs['kolabtargetfolder'])
                except Exception, e:
                    log.error(_("Expunge resource calendar for %s (%s) failed: %r") % (
                        resource_dn, resource_attrs['kolabtargetfolder'], e
                    ))

        imap.disconnect()
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:38,代碼來源:module_resources.py

示例5: resource_records_from_itip_events

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import find_resource [as 別名]
def resource_records_from_itip_events(itip_events):
    """
        Given a list of itip_events, determine which resources have been
        invited as attendees and/or resources.
    """

    auth = Auth()
    auth.connect()

    resource_records = []

    log.debug(_("Raw itip_events: %r") % (itip_events), level=9)
    attendees_raw = []
    for list_attendees_raw in [x for x in [y['attendees'] for y in itip_events if y.has_key('attendees') and isinstance(y['attendees'], list)]]:
        attendees_raw.extend(list_attendees_raw)

    for list_attendees_raw in [y['attendees'] for y in itip_events if y.has_key('attendees') and isinstance(y['attendees'], basestring)]:
        attendees_raw.append(list_attendees_raw)

    log.debug(_("Raw set of attendees: %r") % (attendees_raw), level=9)

    # TODO: Resources are actually not implemented in the format. We reset this
    # list later.
    resources_raw = []
    for list_resources_raw in [x for x in [y['resources'] for y in itip_events if y.has_key('resources')]]:
        resources_raw.extend(list_resources_raw)

    log.debug(_("Raw set of resources: %r") % (resources_raw), level=9)

    # TODO: We expect the format of an attendee line to literally be:
    #
    #   ATTENDEE:RSVP=TRUE;ROLE=REQ-PARTICIPANT;MAILTO:[email protected]
    #
    # which makes the attendees_raw contain:
    #
    #   RSVP=TRUE;ROLE=REQ-PARTICIPANT;MAILTO:[email protected]
    #
    attendees = [x.split(':')[-1] for x in attendees_raw]

    for attendee in attendees:
        log.debug(
                _("Checking if attendee %r is a resource (collection)") % (
                        attendee
                    ),
                level=8
            )

        _resource_records = auth.find_resource(attendee)

        if isinstance(_resource_records, list):
            if len(_resource_records) == 0:
                log.debug(
                        _("No resource (collection) records found for %r") % (
                                attendee
                            ),
                        level=9
                    )

            else:
                log.debug(
                        _("Resource record(s): %r") % (_resource_records),
                        level=8
                    )

                resource_records.extend(_resource_records)
        elif isinstance(_resource_records, basestring):
            log.debug(
                    _("Resource record: %r") % (_resource_records),
                    level=8
                )

            resource_records.append(_resource_records)
        else:
            log.warning(
                    _("Resource reservation made but no resource records found")
                )

    # TODO: Escape the non-implementation of the free-form, undefined RESOURCES
    # list(s) in iTip. We don't know how to handle this yet!
    resources_raw = []

    # TODO: We expect the format of an resource line to literally be:
    #
    #   RESOURCES:MAILTO:[email protected]
    #
    # which makes the resources_raw contain:
    #
    #   MAILTO:[email protected]
    #
    resources = [x.split(':')[-1] for x in resources_raw]
    for resource in resources:
        log.debug(
                _("Checking if resource %r is a resource (collection)") % (
                        resource
                    ),
                level=8
            )

        _resource_records = auth.find_resource(resource)
        if isinstance(_resource_records, list):
#.........這裏部分代碼省略.........
開發者ID:detrout,項目名稱:pykolab,代碼行數:103,代碼來源:module_resources.py

示例6: resource_records_from_itip_events

# 需要導入模塊: from pykolab.auth import Auth [as 別名]
# 或者: from pykolab.auth.Auth import find_resource [as 別名]
def resource_records_from_itip_events(itip_events, recipient_email=None):
    """
        Given a list of itip_events, determine which resources have been
        invited as attendees and/or resources.
    """
    global auth

    if not auth:
        auth = Auth()
        auth.connect()

    resource_records = []

    log.debug(_("Raw itip_events: %r") % (itip_events), level=9)
    attendees_raw = []
    for list_attendees_raw in [x for x in [y['attendees'] for y in itip_events if y.has_key('attendees') and isinstance(y['attendees'], list)]]:
        attendees_raw.extend(list_attendees_raw)

    for list_attendees_raw in [y['attendees'] for y in itip_events if y.has_key('attendees') and isinstance(y['attendees'], basestring)]:
        attendees_raw.append(list_attendees_raw)

    log.debug(_("Raw set of attendees: %r") % (attendees_raw), level=9)

    # TODO: Resources are actually not implemented in the format. We reset this
    # list later.
    resources_raw = []
    for list_resources_raw in [x for x in [y['resources'] for y in itip_events if y.has_key('resources')]]:
        resources_raw.extend(list_resources_raw)

    log.debug(_("Raw set of resources: %r") % (resources_raw), level=9)

    # consider organizer (in REPLY messages), too
    organizers_raw = [re.sub('\+[A-Za-z0-9=/-][email protected]', '@', str(y['organizer'])) for y in itip_events if y.has_key('organizer')]

    log.debug(_("Raw set of organizers: %r") % (organizers_raw), level=8)


    # TODO: We expect the format of an attendee line to literally be:
    #
    #   ATTENDEE:RSVP=TRUE;ROLE=REQ-PARTICIPANT;MAILTO:[email protected]
    #
    # which makes the attendees_raw contain:
    #
    #   RSVP=TRUE;ROLE=REQ-PARTICIPANT;MAILTO:[email protected]
    #
    attendees = [x.split(':')[-1] for x in attendees_raw + organizers_raw]

    # Limit the attendee resources to the one that is actually invited
    # with the current message. Considering all invited resources would result in
    # duplicate responses from every iTip message sent to a resource.
    if recipient_email is not None:
        attendees = [a for a in attendees if a == recipient_email]

    for attendee in attendees:
        log.debug(_("Checking if attendee %r is a resource (collection)") % (attendee), level=8)

        _resource_records = auth.find_resource(attendee)

        if isinstance(_resource_records, list):
            if len(_resource_records) > 0:
                resource_records.extend(_resource_records)
                log.debug(_("Resource record(s): %r") % (_resource_records), level=8)
            else:
                log.debug(_("No resource (collection) records found for %r") % (attendee), level=9)

        elif isinstance(_resource_records, basestring):
            resource_records.append(_resource_records)
            log.debug(_("Resource record: %r") % (_resource_records), level=8)

        else:
            log.warning(_("Resource reservation made but no resource records found"))

    # Escape the non-implementation of the free-form, undefined RESOURCES
    # list(s) in iTip.
    if len(resource_records) == 0:

        # TODO: We don't know how to handle this yet!
        # We expect the format of an resource line to literally be:
        #   RESOURCES:MAILTO:[email protected]
        resources_raw = []

        resources = [x.split(':')[-1] for x in resources_raw]

        # Limit the attendee resources to the one that is actually invited
        # with the current message.
        if recipient_email is not None:
            resources = [a for a in resources if a == recipient_email]

        for resource in resources:
            log.debug(_("Checking if resource %r is a resource (collection)") % (resource), level=8)

            _resource_records = auth.find_resource(resource)
            if isinstance(_resource_records, list):
                if len(_resource_records) > 0:
                    resource_records.extend(_resource_records)
                    log.debug(_("Resource record(s): %r") % (_resource_records), level=8)

                else:
                    log.debug(_("No resource (collection) records found for %r") % (resource), level=8)

#.........這裏部分代碼省略.........
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:103,代碼來源:module_resources.py


注:本文中的pykolab.auth.Auth.find_resource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。