from zope.interface import implements

from twisted.python import usage
from twisted.plugin import IPlugin
from twisted.application.service import IServiceMaker
from twisted.application import internet
from twisted.web import server
from twisted.internet import ssl

import specter


class Options(usage.Options):
    optParameters = [
        ["port", "p", 2400, "The port to listen on"],
        ["config", "c", "specter.yml", "Config file"],
        ["key", None, "specter.key", "SSL key file"],
        ["cert", None, "specter.crt", "SSL certificate file"]
    ]

class SpecterServiceMaker(object):
    implements(IServiceMaker, IPlugin)
    tapname = "specter"
    description = "Distributex - A simple mutex lock service"
    options = Options
    def makeService(self, options):
        return internet.SSLServer(
            int(options['port']),
            server.Site(specter.SiteRoot(options['config'])),
            ssl.DefaultOpenSSLContextFactory(
                options['key'],
                options['cert']
            )
        )

serviceMaker = SpecterServiceMaker()

@@ -1,41 +1,15 @@
-from zope.interface import implements
+import yaml
 %0A%0Afr
@@ -234,16 +234,55 @@
 rt ssl%0A%0A
+from zope.interface import implements%0A%0A
 import s
@@ -455,124 +455,8 @@
 %22%5D,%0A
-        %5B%22key%22, None, %22specter.key%22, %22SSL key file%22%5D,%0A        %5B%22cert%22, None, %22specter.crt%22, %22SSL certificate file%22%5D%0A
     
@@ -672,24 +672,85 @@
 , options):%0A
+        config = yaml.load(open(options%5B'config'%5D))%0A        %0A
         retu
@@ -847,33 +847,22 @@
 iteRoot(
-options%5B'
 config
-'%5D
 )),%0A    
@@ -919,25 +919,28 @@
         
-options%5B'
+config%5B'ssl-
 key'%5D,%0A 
@@ -954,25 +954,28 @@
         
-options%5B'
+config%5B'ssl-
 cert'%5D%0A 

Move config parsing to plugin, use for SSL keys