[CalendarServer-changes] [14804] CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands

source_changes at macosforge.org source_changes at macosforge.org
Tue May 19 14:16:06 PDT 2015


Revision: 14804
          http://trac.calendarserver.org//changeset/14804
Author:   sagen at apple.com
Date:     2015-05-19 14:16:06 -0700 (Tue, 19 May 2015)
Log Message:
-----------
New 'recovertrash' command

Modified Paths:
--------------
    CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py

Added Paths:
-----------
    CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/recovertrash.py

Modified: CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py	2015-05-19 21:15:30 UTC (rev 14803)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py	2015-05-19 21:16:06 UTC (rev 14804)
@@ -39,6 +39,7 @@
     "props",
     "proxies",
     "put",
+    "recovertrash",
     "query",
     "quit",
     "quota",

Added: CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/recovertrash.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/recovertrash.py	                        (rev 0)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/recovertrash.py	2015-05-19 21:16:06 UTC (rev 14804)
@@ -0,0 +1,68 @@
+##
+# Copyright (c) 2007-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from caldavclientlibrary.browser.command import Command, CommandError
+from caldavclientlibrary.browser.command import WrongOptions
+from caldavclientlibrary.protocol.url import URL
+import getopt
+import shlex
+
+class Cmd(Command):
+
+    def __init__(self):
+        super(Command, self).__init__()
+        self.cmds = ("recovertrash",)
+
+
+    def execute(self, cmdname, options):
+
+        principal = self.shell.account.getPrincipal()
+        homeset = principal.homeset
+        if not homeset:
+            print "No calendar home set found for %s" % (principal.principalPath,)
+            raise CommandError
+
+        homepath = homeset[0].path
+
+
+        recoveryID = None
+        mode = "event"
+        opts, args = getopt.getopt(shlex.split(options), "cr:")
+
+        for name, value in opts:
+
+            if name == "-r":
+                recoveryID = value
+            elif name == "-c":
+                mode = "collection"
+            else:
+                print("Unknown option: {}".format(name))
+                print self.usage(cmdname)
+                raise WrongOptions
+
+        resource = URL(url="{}?action=recovertrash&mode={}&id={}".format(homepath, mode, recoveryID))
+        self.shell.account.session.writeData(resource, None, None, method="POST")
+
+        return True
+
+
+    def usage(self, name):
+        return """Usage: %s
+""" % (name,)
+
+
+    def helpDescription(self):
+        return "Get the contents of the trash of the current user."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150519/57aad2c1/attachment-0001.html>


More information about the calendarserver-changes mailing list