4

I'm writing a server with Twisted that is based on a *.tac file that starts the services and the application. I'd like to get one additional command line argument to specify a yaml configuration file. I've tried using usage.Options by building a class that inherits from it, but is choking because of the additional, twistd command line arguments (-y <filename> for example) not being specified in my class Options(...) class.

How can get one additional argument and still pass the rest to twistd? Do I have to do this using the plugin system?

halfer
  • 19,824
  • 17
  • 99
  • 186
writes_on
  • 1,735
  • 2
  • 22
  • 35

1 Answers1

4

A tac file is configuration. It doesn't accept configuration.

If you want to pass command line arguments, you do need to write a plugin.

Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122
  • Thanks Jean-Paul. I guess I haven't seen (or built) enough tac files to know how to use them properly. I want to use a fairly large dictionary (what could come from a yaml file) to configure the system. In particular the Python logging module. Would it be the right thing to do to just embed the dictionary in the tac file and leave it at that? – writes_on Aug 15 '13 at 03:26
  • 1
    You could just embed the name of the yaml file in the tac. Or you could make the path to the yaml file part of some other piece of the program's execution environment (ie, not a command line argument but, say, an environment variable; consider how ld.so and LD_LIBRARY_PATH work; sensible default search paths, but overridable). – Jean-Paul Calderone Aug 15 '13 at 12:07
  • Those sound like workable alternatives. I'm so used to having my configuration outside of the program code in *.yml or *.ini files, it's hard for me to think otherwise. But, your suggestions offer another way to do that. Again, thanks! – writes_on Aug 15 '13 at 14:13