[CalendarServer-changes] [554] CalendarServer/branches/caladmin-tool/caladmin

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 22 11:08:27 PST 2006


Revision: 554
          http://trac.macosforge.org/projects/calendarserver/changeset/554
Author:   dreid at apple.com
Date:     2006-11-22 11:08:26 -0800 (Wed, 22 Nov 2006)

Log Message:
-----------
add principalaction missing from last commit, start.  Support -1 for principaloptions and start support for -d just need to implement util.isPrincipalDisabled

Modified Paths:
--------------
    CalendarServer/branches/caladmin-tool/caladmin/options.py
    CalendarServer/branches/caladmin-tool/caladmin/util.py

Added Paths:
-----------
    CalendarServer/branches/caladmin-tool/caladmin/principals.py

Modified: CalendarServer/branches/caladmin-tool/caladmin/options.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/options.py	2006-11-22 18:47:23 UTC (rev 553)
+++ CalendarServer/branches/caladmin-tool/caladmin/options.py	2006-11-22 19:08:26 UTC (rev 554)
@@ -168,6 +168,8 @@
     action = 'caladmin.principals.PrincipalAction'
 
     optFlags = [
+        ['list', '1', 'List principal names'],
+        ['disabled', 'd', 'List disabled principals'],
         PARAM_HUMAN,
         PARAM_KILO,
         PARAM_MEGA,

Added: CalendarServer/branches/caladmin-tool/caladmin/principals.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/principals.py	                        (rev 0)
+++ CalendarServer/branches/caladmin-tool/caladmin/principals.py	2006-11-22 19:08:26 UTC (rev 554)
@@ -0,0 +1,70 @@
+##
+# 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
+##
+
+from caladmin import util
+
+class PrincipalAction(object):
+    def __init__(self, config, type):
+        self.config = config
+        self.type = type
+
+        self.formatter = self.config.parent.formatter
+        self.root = self.config.parent.root
+        self.calendarCollection = self.config.parent.calendarCollection
+        self.principalCollection = self.config.parent.principalCollection
+        
+    def run(self):
+        if not self.config.params:
+            principals = util.getPrincipalList(self.principalCollection, 
+                                               self.type, 
+                                               disabled=self.config['disabled'])
+
+        else:
+            principals = []
+
+            for p in self.config.params:
+                p = self.principalCollection.child(self.type).child(p)
+
+                if p.exists():
+                    if self.config['disabled']:
+                        if util.isPrincipalDisabled(p):
+                            principals.append(p)
+                    else:
+                        principals.append(p)
+
+        if not self.config['list']:
+            self.formatter.printRow(['Name', 'Calendars', 'Events', 'Todos', 
+                                     'Disk Usage'], 16)
+
+        for p in principals:
+            pcal = self.calendarCollection.child(self.type).child(p.basename())
+            row = []
+
+            row.append(p.basename())
+
+            if not self.config['list']:
+                
+                row.extend(util.getCalendarDataCounts(pcal))
+                
+                row.append(util.prepareByteValue(self.config, 
+                                                 util.getDiskUsage(pcal)))
+                
+            self.formatter.printRow(row, 16)
+
+                    
+                

Modified: CalendarServer/branches/caladmin-tool/caladmin/util.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/util.py	2006-11-22 18:47:23 UTC (rev 553)
+++ CalendarServer/branches/caladmin-tool/caladmin/util.py	2006-11-22 19:08:26 UTC (rev 554)
@@ -57,7 +57,7 @@
     return value
 
 
-def getPrincipalList(principalCollection, type):
+def getPrincipalList(principalCollection, type, disabled=False):
     typeRoot = principalCollection.child(type)
     assert typeRoot.exists()
     
@@ -65,8 +65,14 @@
     
     for child in typeRoot.listdir():
         if child not in ['.db.sqlite']:
-            pl.append(typeRoot.child(child))
+            p = typeRoot.child(child)
 
+            if disabled:
+                if isPrincipalDisabled(p):
+                    pl.append(p)
+            else:
+                pl.append(p)
+
     return pl
 
 
@@ -127,3 +133,7 @@
                 todoCount += 1
 
     return (calCount, eventCount, todoCount)
+
+
+def isPrincipalDisabled(principal):
+    return False

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061122/433a1d62/attachment.html


More information about the calendarserver-changes mailing list