[CalendarServer-changes] [8311] CalendarServer/trunk/calendarserver/tools/shell.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 16 17:08:17 PST 2011
Revision: 8311
http://trac.macosforge.org/projects/calendarserver/changeset/8311
Author: wsanchez at apple.com
Date: 2011-11-16 17:08:15 -0800 (Wed, 16 Nov 2011)
Log Message:
-----------
ls and cd take target arguments
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/shell.py
Modified: CalendarServer/trunk/calendarserver/tools/shell.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell.py 2011-11-17 00:50:03 UTC (rev 8310)
+++ CalendarServer/trunk/calendarserver/tools/shell.py 2011-11-17 01:08:15 UTC (rev 8311)
@@ -246,6 +246,12 @@
else:
self.drawInputLine()
+ def _getTarget(self, tokens):
+ if tokens:
+ return self.wd.locate(tokens.pop(0).split("/"))
+ else:
+ return self.wd
+
def cmd_pwd(self, tokens):
"""
Print working directory.
@@ -277,10 +283,12 @@
"""
List working directory.
"""
+ target = (yield self._getTarget(tokens))
+
if tokens:
raise UnknownArguments(tokens)
- listing = (yield self.wd.list())
+ listing = (yield target.list())
#
# FIXME: this can be ugly if, for example, there are
@@ -295,11 +303,7 @@
"""
Print information about working directory.
"""
- if tokens:
- path = tokens.pop(0)
- target = self.wd.locate(path)
- else:
- target = self.wd
+ target = (yield self._getTarget(tokens))
if tokens:
raise UnknownArguments(tokens)
@@ -347,22 +351,10 @@
returnValue(RootDirectory(self.store))
name = path[0]
- #log.msg(" name: %s" % (name,))
if name:
- path = list(path)
-
- log.msg(" name: %s" % (name,))
- log.msg(" path: %s" % (path,))
-
- path.pop(0)
subdir = (yield self.child(name))
-
- log.msg(" path: %s" % (path,))
- log.msg(" subdir: %s" % (subdir,))
-
- if path:
- subdir = (yield subdir.locate(path))
-
+ if len(path) > 1:
+ subdir = (yield subdir.locate(path[1:]))
else:
subdir = (yield RootDirectory(self.store).locate(path[1:]))
@@ -430,13 +422,16 @@
else:
raise NotFoundError("No calendar home for UID %r" % (name,))
+ @inlineCallbacks
def list(self):
- raise NotImplementedError("UIDDirectory.list() isn't implemented.")
- d = self.store.eachCalendarHome()
- d.addCallback(lambda th: ("%s/" % (h.uid(),) for (t, h) in th))
- return d
+ result = []
+ for txn, home in (yield self.store.eachCalendarHome()):
+ result.append("%s/" % (home.uid(),))
+ returnValue(result)
+
+
class CalendarHomeDirectory(Directory):
"""
Home directory.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111116/9553ef9b/attachment.html>
More information about the calendarserver-changes
mailing list