[CalendarServer-changes] [8277] CalendarServer/trunk/calendarserver/tools/shell.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 11 10:20:57 PST 2011


Revision: 8277
          http://trac.macosforge.org/projects/calendarserver/changeset/8277
Author:   wsanchez at apple.com
Date:     2011-11-11 10:20:57 -0800 (Fri, 11 Nov 2011)
Log Message:
-----------
Don't print traceback for NotImplementedError. Improve describe() for home.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/shell.py

Modified: CalendarServer/trunk/calendarserver/tools/shell.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell.py	2011-11-11 17:43:36 UTC (rev 8276)
+++ CalendarServer/trunk/calendarserver/tools/shell.py	2011-11-11 18:20:57 UTC (rev 8277)
@@ -30,6 +30,7 @@
 from twisted.python.text import wordWrap
 from twisted.python.usage import Options, UsageError
 from twisted.internet.defer import succeed, fail, maybeDeferred, Deferred
+from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.internet.stdio import StandardIO
 from twisted.conch.recvline import HistoricRecvLine as ReceiveLineProtocol
 from twisted.conch.insults.insults import ServerProtocol
@@ -217,9 +218,10 @@
 
                 def handleException(f):
                     self.terminal.write("Error: %s\n" % (f.value,))
-                    log.msg("-"*80 + "\n")
-                    log.msg(f.getTraceback())
-                    log.msg("-"*80 + "\n")
+                    if not f.check(NotImplementedError):
+                        log.msg("-"*80 + "\n")
+                        log.msg(f.getTraceback())
+                        log.msg("-"*80 + "\n")
 
                 def next(_):
                     self.activeCommand = None
@@ -447,26 +449,38 @@
 
         self.home = home
 
+    @inlineCallbacks
     def describe(self):
-        d = maybeDeferred(self.home.quotaUsedBytes)
+        # created() -> int
+        # modified() -> int
+        # properties -> IPropertyStore
 
-        def gotQuotaUsed(quotaUsed):
-            quotaAllowed = self.home.quotaAllowedBytes()
+        uid          = self.home.uid()
+        created      = self.home.created()
+        modified     = self.home.modified()
+        quotaUsed    = (yield self.home.quotaUsedBytes())
+        quotaAllowed = self.home.quotaAllowedBytes()
+        quotaPercent = quotaUsed / quotaAllowed,
+        properties   = self.home.properties()
 
-            return (
-                """Calendar home for UID: %(uid)s\n"""
-                """Quota: %(quotaUsed)s of %(quotaMax)s (%(quotaPercent).2s%%)"""
-                % {
-                    "uid"          : self.home.uid(),
-                    "quotaUsed"    : quotaUsed,
-                    "quotaMax"     : quotaAllowed,
-                    "quotaPercent" : quotaUsed / quotaAllowed,
-                }
-            )
-        d.addCallback(gotQuotaUsed)
+        result = []
+        result.append("Calendar home for UID: %s" % (uid,))
+        if created is not None:
+            # FIXME: convert to string
+            result.append("Created: %s" % (created,))
+        if modified is not None:
+            # FIXME: convert to string
+            result.append("Last modified: %s" % (modified,))
+        if quotaUsed is not None:
+            result.append("Quota: %s of %s (%.2s%%)"
+                          % (quotaUsed, quotaAllowed, quotaUsed / quotaAllowed))
 
-        return d
+        if properties:
+            for name in sorted(properties):
+                result.append("%s: %s" % (name, properties[name]))
 
+        returnValue(result)
+
     def list(self):
         # FIXME
         return succeed(())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111111/872f7650/attachment-0001.html>


More information about the calendarserver-changes mailing list