[Twisted-Python] sub options in twisted applications
Manlio Perillo
manlio_perillo at libero.it
Sun Jun 11 03:48:51 MDT 2006
I don't know if this is useful/safe, but I have written a patch that
allow users to pass additional command line arguments to an application
started with twistd -y.
I don't know if this is compatible with mktap, this is why I have posted
the "patch" here and not on the traker.
########## In twisted.scripts.twistd
def runApp(config):
import sys
sys.argv = appArgv
...
def configHelper(argv):
idx = 1
for i, opt in enumerate(argv[1:]):
if not opt.startswith('-'):
idx = i + 1
break
tmp = argv[idx:]
if len(argv) > idx:
del argv[idx + 1:]
return tmp
appArgv = []
def run():
global appArgv
import sys
appArgv = configHelper(sys.argv)
app.run(runApp, ServerOptions)
#########
Now if I do
twistd -y myapp -x -y
sys.argv is
["myapp", "-x", "-y"]
Regards Manlio Perillo
More information about the Twisted-Python
mailing list