[CalendarServer-changes] [526]
CalendarServer/branches/caladmin-tool/caladmin
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 20 10:22:24 PST 2006
Revision: 526
http://trac.macosforge.org/projects/calendarserver/changeset/526
Author: dreid at apple.com
Date: 2006-11-20 10:22:23 -0800 (Mon, 20 Nov 2006)
Log Message:
-----------
untabify
Modified Paths:
--------------
CalendarServer/branches/caladmin-tool/caladmin/__init__.py
CalendarServer/branches/caladmin-tool/caladmin/caldav.py
CalendarServer/branches/caladmin-tool/caladmin/commands.py
CalendarServer/branches/caladmin-tool/caladmin/formatters.py
CalendarServer/branches/caladmin-tool/caladmin/users.py
Modified: CalendarServer/branches/caladmin-tool/caladmin/__init__.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/__init__.py 2006-11-20 18:12:09 UTC (rev 525)
+++ CalendarServer/branches/caladmin-tool/caladmin/__init__.py 2006-11-20 18:22:23 UTC (rev 526)
@@ -0,0 +1,17 @@
+##
+# Copyright (c) 2006 Apple Computer, 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.
+#
+# DRI: David Reid, dreid at apple.com
+##
Modified: CalendarServer/branches/caladmin-tool/caladmin/caldav.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/caldav.py 2006-11-20 18:12:09 UTC (rev 525)
+++ CalendarServer/branches/caladmin-tool/caladmin/caldav.py 2006-11-20 18:22:23 UTC (rev 526)
@@ -26,92 +26,92 @@
from twisted.web import microdom
defaultPorts = {'https': 443,
- 'http': 80}
+ 'http': 80}
def makeHandle(url, username=None, password=None):
- """Get a ServerHandle for the given url
- """
- scheme, server, path, parameters, query, fragment, = urlparse(url)
-
- port = defaultPorts[scheme]
+ """Get a ServerHandle for the given url
+ """
+ scheme, server, path, parameters, query, fragment, = urlparse(url)
+
+ port = defaultPorts[scheme]
- serverPortList = server.split(':', 1)
- server = serverPortList[0]
- if len(serverPortList) > 1:
- port = int(serverPortList[1])
+ serverPortList = server.split(':', 1)
+ server = serverPortList[0]
+ if len(serverPortList) > 1:
+ port = int(serverPortList[1])
- sh = ServerHandle(host=server,
- port=port,
- username=username,
- password=password)
+ sh = ServerHandle(host=server,
+ port=port,
+ username=username,
+ password=password)
- return sh
+ return sh
def parseQuotaPropfind(response):
- """Generator that yeilds:
- name - a string as derived from basepath on the returned uri.
- total - an integer equal to the available + the used
- used - an integer from quota-used-bytes
- avail - an integer from quota-available-bytes
+ """Generator that yeilds:
+ name - a string as derived from basepath on the returned uri.
+ total - an integer equal to the available + the used
+ used - an integer from quota-used-bytes
+ avail - an integer from quota-available-bytes
- total, used, and available values are given as # of bytes.
+ total, used, and available values are given as # of bytes.
"""
- dom = microdom.parseString(response.body)
-
- for resp in microdom.getElementsByTagName(dom, 'response'):
- href = resp.getElementsByTagName('href'
- )[0].firstChild().toxml()
+ dom = microdom.parseString(response.body)
+
+ for resp in microdom.getElementsByTagName(dom, 'response'):
+ href = resp.getElementsByTagName('href'
+ )[0].firstChild().toxml()
- avail = resp.getElementsByTagName('quota-available-bytes'
- )[0].firstChild()
- used = resp.getElementsByTagName('quota-used-bytes'
- )[0].firstChild()
+ avail = resp.getElementsByTagName('quota-available-bytes'
+ )[0].firstChild()
+ used = resp.getElementsByTagName('quota-used-bytes'
+ )[0].firstChild()
- name = href.split('/')[-2]
+ name = href.split('/')[-2]
- if name in ('users', 'groups', 'resources'):
- continue
+ if name in ('users', 'groups', 'resources'):
+ continue
- if not avail:
- avail = 0
- else:
- avail = int(avail.toxml())
+ if not avail:
+ avail = 0
+ else:
+ avail = int(avail.toxml())
- if not used:
- used = 0
- else:
- used = int(used.toxml())
+ if not used:
+ used = 0
+ else:
+ used = int(used.toxml())
- yield (name, avail+used, used, avail)
-
+ yield (name, avail+used, used, avail)
+
def getQuotaStats(handle, type, entity=None):
- """Utility function for getting a generator as described in
- parseQuotaPropfind given a server handle for the given type
- and possibly a given entity (username, groupname or resource name.)
- """
+ """Utility function for getting a generator as described in
+ parseQuotaPropfind given a server handle for the given type
+ and possibly a given entity (username, groupname or resource name.)
+ """
- path = os.path.join('/calendars', type)
- depth = '1'
+ path = os.path.join('/calendars', type)
+ depth = '1'
- if entity:
- path = os.path.join(path, entity)
- depth = '0'
+ if entity:
+ path = os.path.join(path, entity)
+ depth = '0'
- quotaProps = [PackElement(x) for x in ['quota-available-bytes',
- 'quota-used-bytes']]
+ quotaProps = [PackElement(x) for x in ['quota-available-bytes',
+ 'quota-used-bytes']]
- request = PropfindRequest(
- path,
- depth,
- quotaProps,
- None)
+ request = PropfindRequest(
+ path,
+ depth,
+ quotaProps,
+ None)
- d = handle.addRequest(request)
- d.addCallback(parseQuotaPropfind)
+ d = handle.addRequest(request)
+ d.addCallback(parseQuotaPropfind)
- return d
+ return d
Modified: CalendarServer/branches/caladmin-tool/caladmin/commands.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/commands.py 2006-11-20 18:12:09 UTC (rev 525)
+++ CalendarServer/branches/caladmin-tool/caladmin/commands.py 2006-11-20 18:22:23 UTC (rev 526)
@@ -64,8 +64,8 @@
from twisted.python.failure import Failure
class TwistedSubCommand(SubCommand):
- """Subcommand subclass that calls it's action's run method from within a
- reactor."""
+ """Subcommand subclass that calls it's action's run method from within a
+ reactor."""
def postOptions(self):
Modified: CalendarServer/branches/caladmin-tool/caladmin/formatters.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/formatters.py 2006-11-20 18:12:09 UTC (rev 525)
+++ CalendarServer/branches/caladmin-tool/caladmin/formatters.py 2006-11-20 18:22:23 UTC (rev 526)
@@ -21,41 +21,41 @@
FORMATTERS = {}
def registerFormatter(short, formatter):
- FORMATTERS[short] = formatter
+ FORMATTERS[short] = formatter
def listFormatters():
- return FORMATTERS.keys()
+ return FORMATTERS.keys()
def getFormatter(short):
- return FORMATTERS[short]
+ return FORMATTERS[short]
class BaseFormatter(object):
- def __init__(self, dst=None):
- self.dst = dst
-
- if not self.dst:
- self.dst = sys.stdout
+ def __init__(self, dst=None):
+ self.dst = dst
+
+ if not self.dst:
+ self.dst = sys.stdout
class PlainFormatter(BaseFormatter):
- def printRow(self, row, spacelen):
- for el in row:
- self.dst.write(str(el))
- self.dst.write(' '*(spacelen - len(str(el))))
-
- self.dst.write('\n')
+ def printRow(self, row, spacelen):
+ for el in row:
+ self.dst.write(str(el))
+ self.dst.write(' '*(spacelen - len(str(el))))
+
+ self.dst.write('\n')
registerFormatter('plain', PlainFormatter)
class CsvFormatter(BaseFormatter):
- def printRow(self, row, spacelen):
- for el in row:
- self.dst.write(str(el))
- self.dst.write(',')
-
- self.dst.write('\n')
+ def printRow(self, row, spacelen):
+ for el in row:
+ self.dst.write(str(el))
+ self.dst.write(',')
+
+ self.dst.write('\n')
registerFormatter('csv', CsvFormatter)
Modified: CalendarServer/branches/caladmin-tool/caladmin/users.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/users.py 2006-11-20 18:12:09 UTC (rev 525)
+++ CalendarServer/branches/caladmin-tool/caladmin/users.py 2006-11-20 18:22:23 UTC (rev 526)
@@ -20,60 +20,60 @@
from twisted.python.urlpath import URLPath
class UserAction(object):
- def __init__(self, config):
- self.config = config
- self.formatter = self.config.parent.formatter
+ def __init__(self, config):
+ self.config = config
+ self.formatter = self.config.parent.formatter
- self.users = list(self.config.params)
+ self.users = list(self.config.params)
- def printQuotaHead(self):
- if not self.config['list']:
- self.formatter.printRow(['Name', 'Quota', 'Used', 'Available'], 16)
-
+ def printQuotaHead(self):
+ if not self.config['list']:
+ self.formatter.printRow(['Name', 'Quota', 'Used', 'Available'], 16)
+
- def printRecord(self, record):
- if self.config['list']:
- self.formatter.printRow([record[0]], 0)
- else:
- self.formatter.printRow(record, 16)
+ def printRecord(self, record):
+ if self.config['list']:
+ self.formatter.printRow([record[0]], 0)
+ else:
+ self.formatter.printRow(record, 16)
- def printRecords(self, records):
- self.printQuotaHead()
+ def printRecords(self, records):
+ self.printQuotaHead()
- for record in records:
- self.printRecord(record)
+ for record in records:
+ self.printRecord(record)
- def run(self):
- sh = caldav.makeHandle(self.config['server'],
- self.config['username'],
- self.config['password'])
+ def run(self):
+ sh = caldav.makeHandle(self.config['server'],
+ self.config['username'],
+ self.config['password'])
- if not self.users:
- d = caldav.getQuotaStats(sh, 'users')
- d.addCallback(self.printRecords)
+ if not self.users:
+ d = caldav.getQuotaStats(sh, 'users')
+ d.addCallback(self.printRecords)
- else:
- users = self.users
+ else:
+ users = self.users
- def _getNextUser(ign):
- if users:
- user = users.pop(0)
+ def _getNextUser(ign):
+ if users:
+ user = users.pop(0)
- return _getUser(user)
+ return _getUser(user)
- def _getUser(user):
- d = caldav.getQuotaStats(sh, 'users', user)
- d.addCallback(lambda rec: self.printRecord(list(rec)[0]))
- d.addCallback(_getNextUser)
+ def _getUser(user):
+ d = caldav.getQuotaStats(sh, 'users', user)
+ d.addCallback(lambda rec: self.printRecord(list(rec)[0]))
+ d.addCallback(_getNextUser)
- return d
+ return d
- self.printQuotaHead()
-
- user = users.pop(0)
-
- d = _getUser(user)
+ self.printQuotaHead()
+
+ user = users.pop(0)
+
+ d = _getUser(user)
- return d
+ return d
-
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061120/4901d201/attachment.html
More information about the calendarserver-changes
mailing list