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

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 27 15:12:35 PST 2006


Revision: 588
          http://trac.macosforge.org/projects/calendarserver/changeset/588
Author:   dreid at apple.com
Date:     2006-11-27 15:12:35 -0800 (Mon, 27 Nov 2006)

Log Message:
-----------
Default statsfile location in caldavd.plist and --nooutput and --readonly support for logs command.

Modified Paths:
--------------
    CalendarServer/branches/caladmin-tool/caladmin/logs.py
    CalendarServer/branches/caladmin-tool/caladmin/options.py
    CalendarServer/branches/caladmin-tool/caladmin/util.py
    CalendarServer/branches/caladmin-tool/conf/caldavd.plist
    CalendarServer/branches/caladmin-tool/twistedcaldav/caldavd.py

Modified: CalendarServer/branches/caladmin-tool/caladmin/logs.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/logs.py	2006-11-27 23:02:00 UTC (rev 587)
+++ CalendarServer/branches/caladmin-tool/caladmin/logs.py	2006-11-27 23:12:35 UTC (rev 588)
@@ -126,32 +126,41 @@
     def __init__(self, config):
         self.config = config
 
+        self.noOutput = self.config['nooutput']
+        self.readOnly = self.config['readonly']
+
         self.logfile = self.config['logfile']
         self.stats = Stats(self.config['stats'])
 
     def run(self):
-        for line in self.logfile.open():
-            if line.startswith('Log opened') or line.startswith('Log closed'):
-                continue
-            else:
-                pline = parseCLFLine(line)
 
-                self.stats.addBytes(int(pline[6]))
-                self.stats.addRequest(pline[4].split(' ')[0])
+        if not self.readOnly:
+            for line in self.logfile.open():
+                if (line.startswith('Log opened') or 
+                    line.startswith('Log closed')):
+                    continue
+                else:
+                    pline = parseCLFLine(line)
+                    
+                    self.stats.addBytes(int(pline[6]))
+                    self.stats.addRequest(pline[4].split(' ')[0])
 
-                if len(pline) > 7:
-                    self.stats.addUserAgent(pline[8])
+                    if len(pline) > 7:
+                        self.stats.addUserAgent(pline[8])
 
-        self.stats.save()    
-        
-        report = {
-            'type': 'logs',
-            'data': {
-                'bytesOut': util.prepareByteValue(self.config, 
-                                                  self.stats.getBytes()),
-                'requestCounts': self.stats.getRequests(),
-                'userAgents': self.stats.getUserAgents(),
+            self.stats.save()    
+
+        if not self.noOutput:
+            report = {
+                'type': 'logs',
+                'data': {
+                    'bytesOut': util.prepareByteValue(self.config, 
+                                                      self.stats.getBytes()),
+                    'requestCounts': self.stats.getRequests(),
+                    'userAgents': self.stats.getUserAgents(),
+                    }
                 }
-            }
 
-        return report
+            return report
+
+        return None

Modified: CalendarServer/branches/caladmin-tool/caladmin/options.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/options.py	2006-11-27 23:02:00 UTC (rev 587)
+++ CalendarServer/branches/caladmin-tool/caladmin/options.py	2006-11-27 23:12:35 UTC (rev 588)
@@ -54,8 +54,9 @@
     def postOptions(self):
         
         report = reflect.namedAny(self.action)(self).run()
-        self.parent.formatter.config = self
-        self.parent.formatter.printReport(report)
+        if report:
+            self.parent.formatter.config = self
+            self.parent.formatter.printReport(report)
 
 
 PARAM_HUMAN = ['human', 'h', 'Display byte values in a human readable form.']
@@ -101,7 +102,8 @@
     action = 'caladmin.logs.LogAction'
 
     optFlags = [
-        ['no-output', 'n', 'Do not output anything to stdout'],
+        ['nooutput', 'n', 'Do not output anything to stdout'],
+        ['readonly', 'r', 'Just read the current stats in the statistics file'],
         PARAM_HUMAN,
         PARAM_KILO,
         PARAM_MEGA,
@@ -109,7 +111,7 @@
         ]
     
     optParameters = [
-        ['stats', 's', 'stats.plist',
+        ['stats', 's', caldavd_defaults['ServerStatsFile'],
          ('Path to destination file for statistics. Note: Stats will be '
           'updated if this file already exists.')],
         ]

Modified: CalendarServer/branches/caladmin-tool/caladmin/util.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/util.py	2006-11-27 23:02:00 UTC (rev 587)
+++ CalendarServer/branches/caladmin-tool/caladmin/util.py	2006-11-27 23:12:35 UTC (rev 588)
@@ -59,7 +59,7 @@
 
 def getPrincipalList(principalCollection, type, disabled=False):
     typeRoot = principalCollection.child(type)
-    assert typeRoot.exists()
+    assert typeRoot.exists(), "Does not exist: %s" % typeRoot.path 
     
     pl = []
     

Modified: CalendarServer/branches/caladmin-tool/conf/caldavd.plist
===================================================================
--- CalendarServer/branches/caladmin-tool/conf/caldavd.plist	2006-11-27 23:02:00 UTC (rev 587)
+++ CalendarServer/branches/caladmin-tool/conf/caldavd.plist	2006-11-27 23:12:35 UTC (rev 588)
@@ -50,6 +50,9 @@
   <key>ServerLogFile</key>
   <string>/var/log/caldavd/server.log</string>
 
+  <key>ServerStatsFile</key>
+  <string>/Library/CalendarServer/Documents</string>
+
   <key>ErrorLogFile</key>
   <string>/var/log/caldavd/error.log</string>
 

Modified: CalendarServer/branches/caladmin-tool/twistedcaldav/caldavd.py
===================================================================
--- CalendarServer/branches/caladmin-tool/twistedcaldav/caldavd.py	2006-11-27 23:02:00 UTC (rev 587)
+++ CalendarServer/branches/caladmin-tool/twistedcaldav/caldavd.py	2006-11-27 23:12:35 UTC (rev 588)
@@ -57,6 +57,7 @@
     "NotificationsEnabled": False,
     "NotificationCollectionName": "notifications",
     "ServerLogFile": "/var/log/caldavd/server.log",
+    "ServerStatsFile": "/Library/CalendarServer/stats.plist",
     "ErrorLogFile": "/var/log/caldavd/error.log",
     "PIDFile": "/var/run/caldavd.pid",
     "Repository": "etc/caldavd/repository.xml",

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061127/0580d23f/attachment.html


More information about the calendarserver-changes mailing list