[CalendarServer-changes] [1120] CalendarServer/trunk/twistedcaldav/tap.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 26 13:16:31 PST 2007


Revision: 1120
          http://trac.macosforge.org/projects/calendarserver/changeset/1120
Author:   cdaboo at apple.com
Date:     2007-01-26 13:16:31 -0800 (Fri, 26 Jan 2007)

Log Message:
-----------
Better error checking.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/tap.py

Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py	2007-01-26 19:03:57 UTC (rev 1119)
+++ CalendarServer/trunk/twistedcaldav/tap.py	2007-01-26 21:16:31 UTC (rev 1120)
@@ -127,7 +127,26 @@
         self.parent['logfile'] = config.ErrorLogFile
         self.parent['pidfile'] = config.PIDFile
 
+        # Verify that document root actually exists
+        self.checkDirectory(config.DocumentRoot, "Document root")
+            
+        # Verify that ssl certs exist if needed
+        if config.SSLEnable:
+            self.checkFile(config.SSLPrivateKey, "SSL Private key")
+            self.checkFile(config.SSLCertificate, "SSL Public key")
 
+    def checkDirectory(self, dirpath, description):
+        if not os.path.exists(dirpath):
+            raise ValueError("%s does not exist: %s" % (description, dirpath,))
+        elif not os.path.isdir(dirpath):
+            raise ValueError("%s is not a directory: %s" % (description, dirpath,))
+    
+    def checkFile(self, filepath, description):
+        if not os.path.exists(filepath):
+            raise ValueError("%s does not exist: %s" % (description, filepath,))
+        elif not os.path.isfile(filepath):
+            raise ValueError("%s is not a file: %s" % (description, filepath,))
+
 class CalDAVServiceMaker(object):
     implements(IPlugin, service.IServiceMaker)
 

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


More information about the calendarserver-changes mailing list