Add -p/--protocol to allow only some protocols to be used. twisty
authorMark Hammond <mhammond@skippinet.com.au>
Thu, 12 Mar 2009 22:34:30 +1100
branchtwisty
changeset 87 14e5d7be81ff23c6ab69a7f7b44be8511c5a7818
parent 86 021e64e9ecb8fa95f7a15f1590192fa6f4ac96e6
child 88 d3e18d08271bb40fbbf46469b28f0b5c2b370cf0
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
Add -p/--protocol to allow only some protocols to be used.
server/python/run-raindrop.py
--- a/server/python/run-raindrop.py
+++ b/server/python/run-raindrop.py
@@ -3,16 +3,17 @@
 import sys
 import optparse
 import logging
 
 from twisted.internet import reactor, defer
 
 from junius import model
 from junius import bootstrap
+from junius.sync import get_conductor
 
 logger = logging.getLogger('raindrop')
 
 class HelpFormatter(optparse.IndentedHelpFormatter):
     def format_description(self, description):
         return description
 
 # a decorator for our global functions, so they can force other commands
@@ -39,17 +40,16 @@ def install_accounts(result, parser, opt
 
 def install_files(result, parser, options):
     """Install all local content files into the database"""
     return model.fab_db(update_views=True
             ).addCallback(bootstrap.install_client_files)
 
 def sync_messages(result, parser, options):
     """Synchronize all messages from all accounts"""
-    from junius.sync import get_conductor
     conductor = get_conductor()
     return conductor.sync(None)
 
 def _setup_logging(options):
     init_errors = []
     logging.basicConfig()
     for val in options.log_level: # a list of all --log-level options...
         try:
@@ -94,20 +94,27 @@ def main():
     parser.add_option("-l", "--log-level", action="append",
                       help="Specifies either an integer or a logging module "
                            "constant (such as INFO) to set all logs to the "
                            "specified level.  Optionally can be in the format "
                            "of 'log.name=level' to only set the level of the "
                            "specified log.",
                       default=["INFO"])
 
+    parser.add_option("-p", "--protocol", action="append", dest='protocols',
+                      help="Specifies the protocols to enable.  If not "
+                           "specified, all protocols are enabled")
+
     options, args = parser.parse_args()
 
     _setup_logging(options)
 
+    # do this very early just to set the options
+    get_conductor(options)
+
     # create an initial deferred to perform tasks which must occur before we
     # can start.  The final callback added will fire up the real servers.
     if args and args[0]=='help':
         if args[1:]:
             which = args[1:]
         else:
             which = all_args.keys()
         for this in which: