[CalendarServer-changes] [8938] CalendarServer/trunk/calendarserver/tap/caldav.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 27 13:57:53 PDT 2012


Revision: 8938
          http://trac.macosforge.org/projects/calendarserver/changeset/8938
Author:   sagen at apple.com
Date:     2012-03-27 13:57:53 -0700 (Tue, 27 Mar 2012)
Log Message:
-----------
Wrap the import of manhole_tap in a try in case dependencies are not available.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/caldav.py

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2012-03-27 20:39:57 UTC (rev 8937)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2012-03-27 20:57:53 UTC (rev 8938)
@@ -50,8 +50,6 @@
 from twisted.application.service import MultiService, IServiceMaker
 from twisted.application.service import Service
 
-from twisted.conch.manhole_tap import makeService as manholeMakeService
-
 import twext
 from twext.web2.server import Site
 from twext.python.log import Logger, LoggingMixIn
@@ -655,21 +653,25 @@
 
         # Optionally enable Manhole access
         if config.Manhole.Enabled:
-            portString = "tcp:%d:interface=127.0.0.1" % (config.Manhole.StartingPortNumber + int(config.LogID) + 1,)
-            manholeService = manholeMakeService({
-                "sshPort" : None,
-                "telnetPort" : portString,
-                "namespace" : {
-                    "config" : config,
-                    "service" : result,
-                    "store" : store,
-                    "directory" : result.rootResource.getDirectory(),
-                    },
-                "passwd" : config.Manhole.PasswordFilePath,
-            })
-            manholeService.setServiceParent(result)
-            # Using print because logging isn't ready at this point
-            print "Manhole access enabled: %s" % (portString,)
+            try:
+                from twisted.conch.manhole_tap import makeService as manholeMakeService
+                portString = "tcp:%d:interface=127.0.0.1" % (config.Manhole.StartingPortNumber + int(config.LogID) + 1,)
+                manholeService = manholeMakeService({
+                    "sshPort" : None,
+                    "telnetPort" : portString,
+                    "namespace" : {
+                        "config" : config,
+                        "service" : result,
+                        "store" : store,
+                        "directory" : result.rootResource.getDirectory(),
+                        },
+                    "passwd" : config.Manhole.PasswordFilePath,
+                })
+                manholeService.setServiceParent(result)
+                # Using print because logging isn't ready at this point
+                print "Manhole access enabled: %s" % (portString,)
+            except ImportError:
+                print "Manhole access could not enabled because manhole_tap could not be imported"
 
         return result
 
@@ -1140,19 +1142,23 @@
 
         # Optionally enable Manhole access
         if config.Manhole.Enabled:
-            portString = "tcp:%d:interface=127.0.0.1" % (config.Manhole.StartingPortNumber,)
-            manholeService = manholeMakeService({
-                "sshPort" : None,
-                "telnetPort" : portString,
-                "namespace" : {
-                    "config" : config,
-                    "service" : s,
-                    },
-                "passwd" : config.Manhole.PasswordFilePath,
-            })
-            manholeService.setServiceParent(s)
-            # Using print because logging isn't ready at this point
-            print "Manhole access enabled: %s" % (portString,)
+            try:
+                from twisted.conch.manhole_tap import makeService as manholeMakeService
+                portString = "tcp:%d:interface=127.0.0.1" % (config.Manhole.StartingPortNumber,)
+                manholeService = manholeMakeService({
+                    "sshPort" : None,
+                    "telnetPort" : portString,
+                    "namespace" : {
+                        "config" : config,
+                        "service" : s,
+                        },
+                    "passwd" : config.Manhole.PasswordFilePath,
+                })
+                manholeService.setServiceParent(s)
+                # Using print because logging isn't ready at this point
+                print "Manhole access enabled: %s" % (portString,)
+            except ImportError:
+                print "Manhole access could not enabled because manhole_tap could not be imported"
 
         # Finally, let's get the real show on the road.  Create a service that
         # will spawn all of our worker processes when started, and wrap that
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120327/2b8df979/attachment.html>


More information about the calendarserver-changes mailing list