[CalendarServer-changes] [773] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Dec 8 14:17:31 PST 2006


Revision: 773
          http://trac.macosforge.org/projects/calendarserver/changeset/773
Author:   dreid at apple.com
Date:     2006-12-08 14:17:31 -0800 (Fri, 08 Dec 2006)

Log Message:
-----------
fix caladmin to work with the new twistedcaldav.config and move it into twistedcaldav/admin/

Modified Paths:
--------------
    CalendarServer/trunk/bin/caladmin
    CalendarServer/trunk/twistedcaldav/admin/logs.py
    CalendarServer/trunk/twistedcaldav/admin/options.py
    CalendarServer/trunk/twistedcaldav/admin/principals.py
    CalendarServer/trunk/twistedcaldav/admin/script.py
    CalendarServer/trunk/twistedcaldav/admin/stats.py

Added Paths:
-----------
    CalendarServer/trunk/twistedcaldav/admin/

Removed Paths:
-------------
    CalendarServer/trunk/caladmin/

Modified: CalendarServer/trunk/bin/caladmin
===================================================================
--- CalendarServer/trunk/bin/caladmin	2006-12-08 22:02:43 UTC (rev 772)
+++ CalendarServer/trunk/bin/caladmin	2006-12-08 22:17:31 UTC (rev 773)
@@ -19,10 +19,6 @@
 
 import sys, os
 
-sys.path.insert(0, os.path.join(os.environ['HOME'],
-								'projects', 'CalendarServer',
-								'Twisted'))
-
 if __name__ == '__main__':
-   from caladmin.script import run
+   from twistedcaldav.admin.script import run
    run()

Copied: CalendarServer/trunk/twistedcaldav/admin (from rev 771, CalendarServer/trunk/caladmin)

Modified: CalendarServer/trunk/twistedcaldav/admin/logs.py
===================================================================
--- CalendarServer/trunk/caladmin/logs.py	2006-12-08 22:00:47 UTC (rev 771)
+++ CalendarServer/trunk/twistedcaldav/admin/logs.py	2006-12-08 22:17:31 UTC (rev 773)
@@ -26,7 +26,7 @@
 
 import plistlib
 
-from caladmin import util
+from twistedcaldav.admin import util
 
 statsTemplate = plistlib.Dict(
     bytesOut=0, 

Modified: CalendarServer/trunk/twistedcaldav/admin/options.py
===================================================================
--- CalendarServer/trunk/caladmin/options.py	2006-12-08 22:00:47 UTC (rev 771)
+++ CalendarServer/trunk/twistedcaldav/admin/options.py	2006-12-08 22:17:31 UTC (rev 773)
@@ -66,7 +66,7 @@
     name = 'purge'
     help = ('Keep your store from becoming unnecessarily large by purging '
             'old events.')
-    action = 'caladmin.purge.PurgeAction'
+    action = 'twistedcaldav.admin.purge.PurgeAction'
 
     optParameters = [
         ['days', 'n', 30, 'Age threshold for purging events.'],
@@ -78,7 +78,7 @@
 class StatsOptions(SubCommand):
     name = 'stats'
     help = ('Overall usage statistics.')
-    action = 'caladmin.stats.StatsAction'
+    action = 'twistedcaldav.admin.stats.StatsAction'
 
     optFlags = [
         PARAM_HUMAN,
@@ -91,12 +91,12 @@
 
 
 from twisted.python import filepath
-from twistedcaldav.caldavd import DEFAULTS
+from twistedcaldav import config
 
 class LogOptions(SubCommand):
     name = 'logs'
     help = ('Gather and report useful information from the logfiles.')
-    action = 'caladmin.logs.LogAction'
+    action = 'twistedcaldav.admin.logs.LogAction'
 
     optFlags = [
         ['nooutput', 'n', 'Do not output anything to stdout'],
@@ -127,13 +127,13 @@
     def postOptions(self):
         if not self['logfile']:
             self['logfile'] = filepath.FilePath(
-                self.parent.config['ServerLogFile'])
+                config.ServerLogFile)
         else:
             self['logfile'] = filepath.FilePath(self['logfile'])
 
         if not self['statsfile']:
             self['statsfile'] = filepath.FilePath(
-                self.parent.config['ServerStatsFile'])
+                config.ServerStatsFile)
         else:
             self['statsfile'] = filepath.FilePath(self['statsfile'])
 
@@ -145,7 +145,7 @@
 class PrincipalOptions(SubCommand):
     name = None
     help = ("Gather statistics and act on %s")
-    action = 'caladmin.principals.PrincipalAction'
+    action = 'twistedcaldav.admin.principals.PrincipalAction'
 
     optFlags = [
         ['list', '1', 'List principal names'],

Modified: CalendarServer/trunk/twistedcaldav/admin/principals.py
===================================================================
--- CalendarServer/trunk/caladmin/principals.py	2006-12-08 22:00:47 UTC (rev 771)
+++ CalendarServer/trunk/twistedcaldav/admin/principals.py	2006-12-08 22:17:31 UTC (rev 773)
@@ -23,7 +23,7 @@
   Last login?
 """
 
-from caladmin import util
+from twistedcaldav.admin import util
 
 class PrincipalAction(object):
     def __init__(self, config, type):

Modified: CalendarServer/trunk/twistedcaldav/admin/script.py
===================================================================
--- CalendarServer/trunk/caladmin/script.py	2006-12-08 22:00:47 UTC (rev 771)
+++ CalendarServer/trunk/twistedcaldav/admin/script.py	2006-12-08 22:17:31 UTC (rev 773)
@@ -35,17 +35,17 @@
 
 from plistlib import readPlist
 
-from caladmin import options
-from caladmin import formatters
+from twistedcaldav.admin import options
+from twistedcaldav.admin import formatters
 
-from twistedcaldav.caldavd import DEFAULTS, caldavd
+from twistedcaldav import config
 
 class AdminOptions(usage.Options):
     recursing = 0
     params = ()
 
     optParameters = [
-        ['config', 'c', caldavd().plistfile, "Path to the caldavd.plist"],
+        ['config', 'c', config.DEFAULTPLISTFILE, "Path to the caldavd.plist"],
         ['format', 'f', 'plain', ("Select an appropriate output formatter: "
                                   "%s" % (formatters.listFormatters(),))]
         ]
@@ -84,17 +84,10 @@
 
         if self['config']:
             self['config'] = os.path.abspath(self['config'])
-            try:
-                self.config = readPlist(self['config'])
-            except IOError, err:
-                sys.stderr.write(("Could not open configuration file: %s (%s)\n"
-                                  ) % (err.filename,
-                                       err.strerror))
-                sys.stderr.flush()
+            if os.path.exists(self['config']):
+                config.parseConfig(self['config'])
 
-                self.config = DEFAULTS
-
-        self.root = filepath.FilePath(self.config['DocumentRoot'])
+        self.root = filepath.FilePath(config.DocumentRoot)
         self.calendarCollection = self.root.child('calendars')
         self.principalCollection = self.root.child('principals')
 
@@ -104,24 +97,26 @@
         else:
             raise usage.UsageError("Please specify a valid formatter: %s" % (
                     ', '.join(lf)))
-
+        
+        self.subCommands = options.genSubCommandsDef()
+        self.recursing = 1
+        self.parseOptions(self.params)
+        
         sc = options.listCommands()
+
         if self.subCommand not in sc:
             raise usage.UsageError("Please select one of: %s" % (
                     ', '.join(sorted(sc))))
 
-        self.subCommands = options.genSubCommandsDef()
-        self.recursing = 1
-        self.parseOptions(self.params)
     
 def run():
-    config = AdminOptions()
+    adminOptions = AdminOptions()
 
     try:
-        config.parseOptions(sys.argv[1:])
+        adminOptions.parseOptions(sys.argv[1:])
 
     except usage.UsageError, ue:
-        print config
+        print adminOptions
         if len(sys.argv) > 1:
             cmd = sys.argv[1]
         else:

Modified: CalendarServer/trunk/twistedcaldav/admin/stats.py
===================================================================
--- CalendarServer/trunk/caladmin/stats.py	2006-12-08 22:00:47 UTC (rev 771)
+++ CalendarServer/trunk/twistedcaldav/admin/stats.py	2006-12-08 22:17:31 UTC (rev 773)
@@ -33,7 +33,7 @@
 
 from twistedcaldav import ical
 
-from caladmin import util        
+from twistedcaldav.admin import util        
 
 class StatsAction(object):
     def __init__(self, config):

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


More information about the calendarserver-changes mailing list