[CalendarServer-changes] [9116] CalendarServer/trunk/calendarserver/tools/shell

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 13 18:43:16 PDT 2012


Revision: 9116
          http://trac.macosforge.org/projects/calendarserver/changeset/9116
Author:   wsanchez at apple.com
Date:     2012-04-13 18:43:15 -0700 (Fri, 13 Apr 2012)
Log Message:
-----------
Add cmd_reload.  Woot.

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

Modified: CalendarServer/trunk/calendarserver/tools/shell/cmd.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/cmd.py	2012-04-14 01:17:01 UTC (rev 9115)
+++ CalendarServer/trunk/calendarserver/tools/shell/cmd.py	2012-04-14 01:43:15 UTC (rev 9116)
@@ -547,7 +547,7 @@
             % (total, toPurge)
         )
 
-    cmd_purge_principals.hidden = "Incomplete."
+    cmd_purge_principals.hidden = "incomplete"
 
     #
     # Python prompt, for the win
@@ -641,6 +641,26 @@
     #
 
     def cmd_raise(self, tokens):
+        """
+        Raises an exception.
+        """
         raise RuntimeError(" ".join(tokens))
 
     cmd_raise.hidden = "test tool"
+
+    def cmd_reload(self, tokens):
+        """
+        Reloads code.
+        """
+        if tokens:
+            raise UnknownArguments(tokens)
+
+        import calendarserver.tools.shell.vfs
+        reload(calendarserver.tools.shell.vfs)
+
+        import calendarserver.tools.shell.directory
+        reload(calendarserver.tools.shell.directory)
+
+        self.protocol.reloadCommands()
+
+    cmd_reload.hidden = "test tool"

Modified: CalendarServer/trunk/calendarserver/tools/shell/terminal.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/terminal.py	2012-04-14 01:17:01 UTC (rev 9115)
+++ CalendarServer/trunk/calendarserver/tools/shell/terminal.py	2012-04-14 01:43:15 UTC (rev 9116)
@@ -143,6 +143,15 @@
         self.activeCommand = None
         self.emulate = "emacs"
 
+    def reloadCommands(self):
+        # FIXME: doesn't work for alternative Commands classes passed
+        # to __init__.
+        self.terminal.write("Reloading commands class...\n")
+
+        import calendarserver.tools.shell.cmd
+        reload(calendarserver.tools.shell.cmd)
+        self.commands = calendarserver.tools.shell.cmd.Commands(self)
+
     #
     # Input handling
     #
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120413/15b1db83/attachment.html>


More information about the calendarserver-changes mailing list