[CalendarServer-changes] [1608] CalendarServer/trunk/twistedcaldav/admin/util.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 18 13:43:16 PDT 2007


Revision: 1608
          http://trac.macosforge.org/projects/calendarserver/changeset/1608
Author:   dreid at apple.com
Date:     2007-06-18 13:43:15 -0700 (Mon, 18 Jun 2007)

Log Message:
-----------
Check for the existence of the typeRoot when returning the principalList, this fixes problems where some directories are not provisioned, (such as resources) and we don't want the exception to stop printing of all the statistics.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/admin/util.py

Modified: CalendarServer/trunk/twistedcaldav/admin/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/util.py	2007-06-18 19:33:05 UTC (rev 1607)
+++ CalendarServer/trunk/twistedcaldav/admin/util.py	2007-06-18 20:43:15 UTC (rev 1608)
@@ -23,7 +23,7 @@
 from twisted.web import microdom
 
 from twistedcaldav import ical
- 
+
 def prepareByteValue(config, value):
     if config.get('human', None):
         KB = value/1024.0
@@ -61,16 +61,17 @@
     typeRoot = principalCollection.child(type)
 
     pl = []
-    
-    for child in typeRoot.listdir():
-        if child not in ['.db.sqlite']:
-            p = typeRoot.child(child)
 
-            if disabled:
-                if isPrincipalDisabled(p):
+    if typeRoot.exists():
+        for child in typeRoot.listdir():
+            if child not in ['.db.sqlite']:
+                p = typeRoot.child(child)
+
+                if disabled:
+                    if isPrincipalDisabled(p):
+                        pl.append(p)
+                else:
                     pl.append(p)
-            else:
-                pl.append(p)
 
     return pl
 
@@ -78,7 +79,7 @@
 def getDiskUsage(config, fp):
     status, output = commands.getstatusoutput(
         ' '.join(['/usr/bin/du', '-s', fp.path]))
-    
+
     if status != 0:
         return 0
 
@@ -90,7 +91,7 @@
     x = xattr.xattr(fp.path)
     if not x.has_key(rt):
         return None
-    
+
     collection = False
 
     type = None
@@ -123,14 +124,14 @@
             except ValueError:
                 # not a calendar file
                 continue
-            
+
             if component.resourceType() == 'VEVENT':
                 eventCount += 1
-                
+
             elif component.resourceType() == 'VTODO':
                 todoCount += 1
 
-    return {'calendarCount': calCount, 
+    return {'calendarCount': calCount,
             'eventCount': eventCount,
             'todoCount': todoCount}
 
@@ -184,11 +185,11 @@
     principalUsed = getQuotaUsed(principal)
     if not principalUsed:
         principalUsed = 0
-        
+
     principalAvail = principalQuota - principalUsed
     principalFree = (float(principalAvail)/principalQuota)*100
 
-    return {'quotaRoot': prepareByteValue(config, principalQuota), 
+    return {'quotaRoot': prepareByteValue(config, principalQuota),
             'quotaUsed': prepareByteValue(config, principalUsed),
             'quotaAvail': prepareByteValue(config, principalAvail),
             'quotaFree': principalFree}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070618/9901b828/attachment.html


More information about the calendarserver-changes mailing list