[CalendarServer-changes] [12001] CalendarServer/trunk/twext/application/masterchild.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:20:19 PDT 2014
Revision: 12001
http://trac.calendarserver.org//changeset/12001
Author: wsanchez at apple.com
Date: 2013-11-22 18:21:22 -0800 (Fri, 22 Nov 2013)
Log Message:
-----------
child now takes a protocol as a CLI argument
Modified Paths:
--------------
CalendarServer/trunk/twext/application/masterchild.py
Modified: CalendarServer/trunk/twext/application/masterchild.py
===================================================================
--- CalendarServer/trunk/twext/application/masterchild.py 2013-11-23 02:21:00 UTC (rev 12000)
+++ CalendarServer/trunk/twext/application/masterchild.py 2013-11-23 02:21:22 UTC (rev 12001)
@@ -25,11 +25,13 @@
from twisted.python.sendmsg import getsockfam
from twisted.python.usage import Options, UsageError
+from twisted.python.reflect import namedClass
from twisted.application.service import MultiService, Service
from twisted.application.service import IServiceMaker
from twisted.application.internet import TCPServer
from twisted.protocols.policies import WrappingFactory, ProtocolWrapper
+from twisted.internet.protocol import ServerFactory
from twisted.internet.protocol import ProcessProtocol
from twext.internet.sendfdport import InheritingProtocolFactory
from twext.internet.sendfdport import InheritedSocketDispatcher
@@ -165,6 +167,7 @@
if fd < 0:
raise ValueError("must be >=0")
+
except ValueError as e:
raise UsageError(
"Invalid file descriptor {0!r}: {1}".format(value, e)
@@ -173,16 +176,30 @@
self["inherited-fd"] = fd
+ def opt_protocol(self, value):
+ """
+ Protocol
+ """
+ try:
+ protocol = namedClass(value)
+ except (ValueError, AttributeError):
+ raise UsageError("Unknown protocol: {0}".format(value))
+
+ self["protocol"] = protocol
+
+
def postOptions(self):
- if "inherited-fd" not in self:
- raise UsageError("inherited-fd paramater is required")
+ for parameter in ("inherited-fd", "protocol"):
+ if parameter not in self:
+ raise UsageError("{0} parameter is required".format(parameter))
@implementer(IServiceMaker)
class ChildServiceMaker(object):
def makeService(self, options):
- service = ChildService(options["inherited-fd"], self.protocolFactory)
+ factory = ServerFactory.forProtocol(options["protocol"])
+ service = ChildService(options["inherited-fd"], factory)
return service
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/99d64c66/attachment.html>
More information about the calendarserver-changes
mailing list