[CalendarServer-changes] [9115] CalendarServer/trunk/calendarserver/tools/shell/cmd.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 13 18:17:01 PDT 2012
Revision: 9115
http://trac.macosforge.org/projects/calendarserver/changeset/9115
Author: wsanchez at apple.com
Date: 2012-04-13 18:17:01 -0700 (Fri, 13 Apr 2012)
Log Message:
-----------
Start cmd_purge_principals
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/shell/cmd.py
Modified: CalendarServer/trunk/calendarserver/tools/shell/cmd.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/cmd.py 2012-04-14 01:12:53 UTC (rev 9114)
+++ CalendarServer/trunk/calendarserver/tools/shell/cmd.py 2012-04-14 01:17:01 UTC (rev 9115)
@@ -33,7 +33,9 @@
from txdav.common.icommondatastore import NotFoundError
+from calendarserver.tap.util import getRootResource
from calendarserver.tools.tables import Table
+from calendarserver.tools.purge import purgeUID
from calendarserver.tools.shell.vfs import Folder, RootFolder
from calendarserver.tools.shell.directory import findRecords, summarizeRecords, recordInfo
@@ -490,6 +492,64 @@
#
+ # Data purge tools
+ #
+
+ @inlineCallbacks
+ def cmd_purge_principals(self, tokens):
+ dryRun = True
+ completely = False
+ doimplicit = True
+
+ directory = self.protocol.service.directory
+
+ uids = tuple(tokens)
+
+ error = False
+ for uid in uids:
+ record = directory.recordWithUID(uid)
+ if not record:
+ self.terminal.write("Unknown UID: %s\n" % (uid,))
+ error = True
+
+ if error:
+ self.terminal.write("Aborting.\n")
+ return
+
+ rootResource = getRootResource(
+ self.protocol.service.config,
+ self.protocol.service.store,
+ )
+
+ if dryRun:
+ toPurge = "to purge"
+ else:
+ toPurge = "purged"
+
+ total = 0
+ for uid in uids:
+ count, assignments = (yield purgeUID(
+ uid, directory, rootResource,
+ verbose = False,
+ dryrun = dryRun,
+ completely = completely,
+ doimplicit = doimplicit,
+ ))
+ total += count
+
+ self.terminal.write(
+ "%d events %s for UID %s.\n"
+ % (count, toPurge, uid)
+ )
+
+ self.terminal.write(
+ "%d total events %s.\n"
+ % (total, toPurge)
+ )
+
+ cmd_purge_principals.hidden = "Incomplete."
+
+ #
# Python prompt, for the win
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120413/cf8fd1a3/attachment.html>
More information about the calendarserver-changes
mailing list