I wrote a Twisted bin file that was deployed to /usr/bin during application deployment, based on the Axiom example provided elsewhere on StackOverflow (I donβt remember where), the project can be found here .
My problem is that during the python setup.py install process, the installed bin file is different from the file from the Axiom package:
/ Usr / bin / axiom
/ Usr / bin / myapp
#!/code/venv/bin/python
and the latter does not work when called from bash shell: myapp start
I get the following error: unknow command myapp
If I use python setup.py develop instead of python setup.py install , everything works smoothly.
I have a small test application that starts the tcp service on port 1234:
- the
twistd finger command works , the service starts fingerize start command (another name for the purpose, so as not to cause the wrong one) does not work
Here is the code:
bin / fingerize
twisted / plugins / finger_plugin.py
from twisted.application.service import ServiceMaker Finger = ServiceMaker('Finger', 'finger.plugins', 'blah', 'finger')
finger /plugins.py
from twisted.application import internet from twisted.internet import endpoints from twisted.python import usage from twisted.internet import protocol class Options(usage.Options): """ """ def makeService(options): from twisted.internet import reactor endpoint = endpoints.TCP4ServerEndpoint(reactor, 1234) return internet.StreamServerEndpointService( endpoint, protocol.Factory())
finger /tap.py
import sys from twisted.python import usage from twisted.scripts import twistd class Start(twistd.ServerOptions): run = staticmethod(twistd.run) def subCommands(self): raise AttributeError() subCommands = property(subCommands) def parseOptions(self, args): print(sys.argv) print(args) a = self.getArguments(args) print(a) sys.argv[1:] = a print(sys.argv) print('Starting finger service...') self.run() def getArguments(self, args): args.extend(['--pidfile', self.parent.pid()]) args.extend(['finger']) return args class Options(usage.Options): def subCommands(): def get(self): yield ('start', None, Start, 'Launch finger service') return get, subCommands = property(*subCommands()) def pid(self): return '/tmp/finger.pid' def main(argv=None): o = Options() try: o.parseOptions(argv) except usage.UsageError, e: raise SystemExit(str(e))
setup.py
from setuptools import find_packages from setuptools import setup METADATA = dict( name='Finger', version='0.0.1', packages=find_packages(), scripts=['bin/fingerize'], install_requires=[ 'Twisted >= 15.5.0', ], include_package_data=True, zip_safe=False, ) setup(**METADATA)
And when I call fingerize start , I get: /code/test/bin/fingerize: Unknown command: finger (test - virtualenv)