[CalendarServer-changes] [4161] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 4 09:42:40 PDT 2009
Revision: 4161
http://trac.macosforge.org/projects/calendarserver/changeset/4161
Author: sagen at apple.com
Date: 2009-05-04 09:42:39 -0700 (Mon, 04 May 2009)
Log Message:
-----------
Adds --search to caldav_utility
Modified Paths:
--------------
CalendarServer/trunk/bin/caldav_utility
CalendarServer/trunk/doc/caldav_utility.8
Modified: CalendarServer/trunk/bin/caldav_utility
===================================================================
--- CalendarServer/trunk/bin/caldav_utility 2009-05-04 13:52:37 UTC (rev 4160)
+++ CalendarServer/trunk/bin/caldav_utility 2009-05-04 16:42:39 UTC (rev 4161)
@@ -39,6 +39,7 @@
from calendarserver.provision.root import RootResource
from getopt import getopt, GetoptError
+import operator
from twisted.internet import reactor
from twisted.internet.address import IPv4Address
from twisted.internet.defer import inlineCallbacks, returnValue, succeed
@@ -71,6 +72,7 @@
print " -h --help: print this help and exit"
print " -f --config <path>: Specify caldavd.plist configuration path"
print " --resource <prinicpal-path>: path of the resource to use"
+ print " --search <search-string>: search for matching resources"
print " --read-property: namespace-qualified DAV property to read, e.g. 'DAV:#group-member-set'"
print " --list-read-delegates: list delegates with read-only access to the current resource"
print " --list-write-delegates: list delegates with read-write access to the current resource"
@@ -93,10 +95,11 @@
def main():
try:
(optargs, args) = getopt(
- sys.argv[1:], "hf:r:s", [
+ sys.argv[1:], "hf:r:s:", [
"config=",
"help",
"resource=",
+ "search=",
"read-property=",
"list-read-delegates",
"list-write-delegates",
@@ -140,6 +143,8 @@
@inlineCallbacks
def run(directory, root, optargs):
+ print ""
+
resource = None
for opt, arg in optargs:
@@ -151,6 +156,33 @@
else:
abort("Could not find resource at %s" % (arg,))
+ elif opt in ("-s", "--search",):
+ fields = []
+ for fieldName in ("fullName", "firstName", "lastName",
+ "emailAddresses"):
+ fields.append((fieldName, arg, True, "contains"))
+
+ records = list((yield directory.recordsMatchingFields(fields)))
+ if records:
+ records.sort(key=operator.attrgetter('fullName'))
+ print "%d matches found:" % (len(records),)
+ for record in records:
+ print "\n%s (%s)" % (record.fullName,
+ { "users" : "User",
+ "groups" : "Group",
+ "locations" : "Place",
+ "resources" : "Resource",
+ }.get(record.recordType),
+ )
+ print record.guid
+ print " Record names: %s" % (", ".join(record.shortNames),)
+ if record.authIDs:
+ print " Auth IDs: %s" % (", ".join(record.authIDs),)
+ if record.emailAddresses:
+ print " Emails: %s" % (", ".join(record.emailAddresses),)
+ else:
+ print "No matches found"
+
elif opt in ("--read-property",):
if resource is None: abort("No current resource.")
@@ -203,6 +235,7 @@
result = (yield resource.getAutoSchedule())
print "Auto-Schedule: %s" % ("True" if result else "False",)
+ print ""
# reactor.callLater(0, reactor.stop)
reactor.stop()
Modified: CalendarServer/trunk/doc/caldav_utility.8
===================================================================
--- CalendarServer/trunk/doc/caldav_utility.8 2009-05-04 13:52:37 UTC (rev 4160)
+++ CalendarServer/trunk/doc/caldav_utility.8 2009-05-04 16:42:39 UTC (rev 4161)
@@ -24,6 +24,7 @@
.Nm
.Op Fl -config Ar config_file
.Op Fl -resource Ar guid
+.Op Fl -search Ar search-term
.Op Fl -read-property Ar dav_property
.Op Fl -list-read-delegates
.Op Fl -list-write-delegates
@@ -50,6 +51,8 @@
Use the Calendar Server configuration specified in the given file. Defaults to /etc/caldavd/caldavd.plist.
.It Fl -resource Ar guid
Specifies the resource the following operations should be applied to.
+.It Fl s, -search Ar search_term
+Search for records matching search_term.
.It Fl -read-property Ar dav_property
Prints the value of the dav_property on the current resource. The format of
the dav_property is "namespace#property". Examples:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090504/539960b0/attachment.html>
More information about the calendarserver-changes
mailing list