本文整理汇总了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'])
示例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
示例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
示例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()
示例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):
#.........这里部分代码省略.........
示例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)
#.........这里部分代码省略.........