[CalendarServer-changes] [7666] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 24 15:05:57 PDT 2011
Revision: 7666
http://trac.macosforge.org/projects/calendarserver/changeset/7666
Author: wsanchez at apple.com
Date: 2011-06-24 15:05:57 -0700 (Fri, 24 Jun 2011)
Log Message:
-----------
Shell of a shell
Added Paths:
-----------
CalendarServer/trunk/bin/calendarserver_shell
CalendarServer/trunk/calendarserver/tools/shell.py
Added: CalendarServer/trunk/bin/calendarserver_shell
===================================================================
--- CalendarServer/trunk/bin/calendarserver_shell (rev 0)
+++ CalendarServer/trunk/bin/calendarserver_shell 2011-06-24 22:05:57 UTC (rev 7666)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+##
+# Copyright (c) 2006-2007 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.
+##
+
+import sys
+
+#PYTHONPATH
+
+if __name__ == "__main__":
+ if "PYTHONPATH" in globals():
+ sys.path.insert(0, PYTHONPATH)
+ else:
+ from os.path import dirname, abspath, join
+ from subprocess import Popen, PIPE
+
+ home = dirname(dirname(abspath(__file__)))
+ run = join(home, "run")
+
+ child = Popen((run, "-p"), stdout=PIPE)
+ path, stderr = child.communicate()
+
+ path = path.rstrip("\n")
+
+ if child.wait() == 0:
+ sys.path[0:0] = path.split(":")
+
+ sys.argv[1:1] = ["-f", join(home, "conf", "caldavd-dev.plist")]
+
+ from calendarserver.tools.shell import main
+ main()
Property changes on: CalendarServer/trunk/bin/calendarserver_shell
___________________________________________________________________
Added: svn:executable
+ *
Added: CalendarServer/trunk/calendarserver/tools/shell.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell.py (rev 0)
+++ CalendarServer/trunk/calendarserver/tools/shell.py 2011-06-24 22:05:57 UTC (rev 7666)
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+# -*- test-case-name: calendarserver.tools.test.test_export -*-
+##
+# Copyright (c) 2011 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.
+##
+
+"""
+Interactive shell for navigating the data store.
+"""
+
+import os
+import sys
+
+from twisted.python.text import wordWrap
+from twisted.python.usage import Options, UsageError
+from twisted.application.service import Service
+
+from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
+
+from calendarserver.tools.cmdline import utilityMain
+
+
+def usage(e=None):
+ if e:
+ print e
+ print ""
+ try:
+ ShellOptions().opt_help()
+ except SystemExit:
+ pass
+ if e:
+ sys.exit(64)
+ else:
+ sys.exit(0)
+
+
+class ShellOptions(Options):
+ """
+ Command line options for "calendarserver_shell".
+ """
+ synopsis = "\n".join(
+ wordWrap(
+ """
+ Usage: calendarserver_shell [options]\n
+ """ + __doc__,
+ int(os.environ.get("COLUMNS", "80"))
+ )
+ )
+
+ optParameters = [
+ ["config", "f", DEFAULT_CONFIG_FILE, "Specify caldavd.plist configuration path."],
+ ]
+
+ def __init__(self):
+ super(ShellOptions, self).__init__()
+
+
+class ShellService(Service):
+ def __init__(self, store, options, reactor, config):
+ super(ShellService, self).__init__()
+ self.store = store
+ self.options = options
+ self.reactor = reactor
+ self.config = config
+
+ def startService(self):
+ """
+ Start the service.
+ """
+ super(ShellService, self).startService()
+ self.shell()
+
+ def stopService(self):
+ """
+ Stop the service.
+ """
+
+ def shell(self):
+ """
+ Interactive shell
+ """
+ print "This is a shell, yo."
+
+
+def main(argv=sys.argv, stderr=sys.stderr, reactor=None):
+ """
+ Do the export.
+ """
+ if reactor is None:
+ from twisted.internet import reactor
+
+ options = ShellOptions()
+ try:
+ options.parseOptions(argv[1:])
+ except UsageError, e:
+ usage(e)
+
+ def makeService(store):
+ from twistedcaldav.config import config
+ return ShellService(store, options, reactor, config)
+
+ utilityMain(options["config"], makeService, reactor)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110624/a56b96d0/attachment-0001.html>
More information about the calendarserver-changes
mailing list