2014-11-02 22 views
2

这里是我twistd插件,它位于project_root/twisted/plugins/my_plugin.py的当前状态:为什么我在没有选项的情况下运行`twistd`命令时不会显示我的扭曲插件?

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 
from zope.interface import implements 

from twisted.plugin import IPlugin 
from twisted.python.usage import Options 
from twisted.application import internet, service 

from mylib.io import MyFactory 


class Options(Options): 
    """Flags and options for the plugin.""" 

    optParameters = [ 
     ('sock', 's', '/tmp/io.sock', 'Path to IO socket'), 
    ] 


class MyServiceMaker(object): 
    implements(service.IServiceMaker, IPlugin) 

    tapname = "myplugin" 
    description = "description for my plugin" 
    options = Options 

    def makeService(self, options): 
     return internet.UNIXServer(options['sock'], MyFactory()) 
  • 没有__init__.py文件中project_root/twisted/plugins/
  • twistd输出不显示我的插件时,从项目的根目录运行
  • 我通过python setup.py develop --user安装了我的库,它可以从任何地方导入

任何想法?

回答

2

为可疑,这是一件非常简单:我需要实例化的MyServiceMaker一个实例,因此只需在脚本的底部添加service_maker = MyServiceMaker()修复该问题。

+0

我有同样的问题......但我没有忘记你做过的事情。 – rschwieb 2017-07-07 19:02:26

相关问题