[CalendarServer-changes] [12859] CalendarServer/branches/users/sagen/move2who
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 7 17:53:15 PST 2014
Revision: 12859
http://trac.calendarserver.org//changeset/12859
Author: sagen at apple.com
Date: 2014-03-07 17:53:15 -0800 (Fri, 07 Mar 2014)
Log Message:
-----------
Handle (some of the) AttributeErrors on emailAddresses
Modified Paths:
--------------
CalendarServer/branches/users/sagen/move2who/calendarserver/tools/principals.py
CalendarServer/branches/users/sagen/move2who/calendarserver/tools/shell/directory.py
CalendarServer/branches/users/sagen/move2who/txdav/caldav/datastore/scheduling/imip/inbound.py
Modified: CalendarServer/branches/users/sagen/move2who/calendarserver/tools/principals.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who/calendarserver/tools/principals.py 2014-03-08 01:31:09 UTC (rev 12858)
+++ CalendarServer/branches/users/sagen/move2who/calendarserver/tools/principals.py 2014-03-08 01:53:15 UTC (rev 12859)
@@ -427,18 +427,31 @@
records = list((yield directory.recordsMatchingTokens(searchTerm.strip().split())))
if records:
records.sort(key=operator.attrgetter('fullNames'))
- print("%d matches found:" % (len(records),))
+ print("{n} matches found:".format(n=len(records)))
for record in records:
print(
- "\n{d} {rt}".format(
+ "\n{d} ({rt})".format(
d=record.displayName,
rt=record.recordType.name
)
)
- print(" UID: %s" % (record.uid,))
- print(" Record name(s): %s" % (", ".join(record.shortNames),))
- if record.emailAddresses:
- print(" Email(s): %s" % (", ".join(record.emailAddresses),))
+ print(" UID: {u}".format(u=record.uid,))
+ print(
+ " Record name{plural}: {names}".format(
+ plural=("s" if len(record.shortNames) > 1 else ""),
+ names=(", ".join(record.shortNames))
+ )
+ )
+ try:
+ if record.emailAddresses:
+ print(
+ " Email{plural}: {emails}".format(
+ plural=("s" if len(record.emailAddresses) > 1 else ""),
+ emails=(", ".join(record.emailAddresses))
+ )
+ )
+ except AttributeError:
+ pass
else:
print("No matches found")
Modified: CalendarServer/branches/users/sagen/move2who/calendarserver/tools/shell/directory.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who/calendarserver/tools/shell/directory.py 2014-03-08 01:31:09 UTC (rev 12858)
+++ CalendarServer/branches/users/sagen/move2who/calendarserver/tools/shell/directory.py 2014-03-08 01:53:15 UTC (rev 12859)
@@ -83,11 +83,17 @@
add("First Name", record.firstName)
add("Last Name" , record.lastName )
- for email in record.emailAddresses:
- add("Email Address", email)
+ try:
+ for email in record.emailAddresses:
+ add("Email Address", email)
+ except AttributeError:
+ pass
- for cua in record.calendarUserAddresses:
- add("Calendar User Address", cua)
+ try:
+ for cua in record.calendarUserAddresses:
+ add("Calendar User Address", cua)
+ except AttributeError:
+ pass
add("Server ID" , record.serverID)
add("Enabled" , record.enabled)
Modified: CalendarServer/branches/users/sagen/move2who/txdav/caldav/datastore/scheduling/imip/inbound.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who/txdav/caldav/datastore/scheduling/imip/inbound.py 2014-03-08 01:31:09 UTC (rev 12858)
+++ CalendarServer/branches/users/sagen/move2who/txdav/caldav/datastore/scheduling/imip/inbound.py 2014-03-08 01:53:15 UTC (rev 12859)
@@ -330,8 +330,11 @@
elif organizer.startswith("urn:uuid:"):
guid = organizer[9:]
record = yield self.directory.recordWithGUID(guid)
- if record and record.emailAddresses:
- toAddr = list(record.emailAddresses)[0]
+ try:
+ if record and record.emailAddresses:
+ toAddr = list(record.emailAddresses)[0]
+ except AttributeError:
+ pass
if toAddr is None:
log.error("Don't have an email address for the organizer; "
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140307/e3b706a5/attachment-0001.html>
More information about the calendarserver-changes
mailing list