I try to write the plugin now:
…
from zope.interface import implements
from twisted.application.service import IServiceMaker
from twisted.application import internet
from twisted.plugin import IPlugin
from twisted.python import usage
from meteo import meteoFactory
class Options(usage.Options):
optParameters = [ ['port', 'p', 80, 'The port number to listen on.'],
['ipv4_address', '4', None, 'The IPv4 address to listen on.'],
['ipv6_address', '6', None, 'The IPv6 address to listen on.']]
class MeteoServiceMaker(object):
implements(IServiceMaker, IPlugin)
tapname = 'meteo'
description = 'A web application for the meteo package'
options = Options
def makeService(self, options):
"""
Constructs a TCP server from a factory defined in meteo.py
"""
return internet.TCPServer( int(options['port'],
interface=options['ipv4_address'], ## how do it set the ip6 address?
meteoFactory())
serviceMaker = MeteoServiceMaker()
---
--- relevant part of metro.py:
resource = RootWeatherPage()
meteoFactory = Site(resource)
---
Currently, this gives following error:
---
[meteo] [www4:py-venv/meteo/meteo] root# twistd --help
Unhandled Error
Traceback (most recent call last):
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/usage.py", line 450, in __str__
return self.getSynopsis() + '\n' + self.getUsage(width=None)
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/usage.py", line 486, in getUsage
for (cmd, short, parser, desc) in self.subCommands:
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/application/app.py", line 631, in subCommands
for plug in sorted(plugins, key=attrgetter('tapname')):
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/plugin.py", line 209, in getPlugins
allDropins = getCache(package)
--- <exception caught here> ---
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/plugin.py", line 167, in getCache
provider = pluginModule.load()
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/modules.py", line 383, in load
return self.pathEntry.pythonPath.moduleLoader(self.name)
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/_reflectpy3.py", line 266, in namedAny
topLevelPackage = _importAndCheckStack(trialname)
File "/usr/local/py-venv/meteo/lib/python2.7/site-packages/twisted/python/_reflectpy3.py", line 205, in _importAndCheckStack
return __import__(importName)
exceptions.SyntaxError: invalid syntax (meteo_plugin.py, line 29)
---
Line 29 is
serviceMaker = MeteoServiceMaker()
What is wrong there?
Thanks,
Axel
---
PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius