londiste x.ini show-handlers: info about handlers
authorMarko Kreen <markokr@gmail.com>
Wed, 21 Sep 2011 13:22:12 +0000 (16:22 +0300)
committerMarko Kreen <markokr@gmail.com>
Wed, 21 Sep 2011 13:43:04 +0000 (16:43 +0300)
python/londiste.py
python/londiste/handler.py
python/londiste/setup.py

index 0b938dbe6dea897bfcbb7293752abb8f44222f30..542c9c5d5e86a5034560f7080c78e873290a8342 100755 (executable)
@@ -37,6 +37,7 @@ Replication Extra:
   compare [TBL ...]     compare table contents on both sides
   repair [TBL ...]      repair data on subscriber
   execute [FILE ...]    execute SQL files on set
+  show-handlers [..]    show info about all or specific handler
 
 Internal Commands:
   copy                  copy table logic
@@ -48,6 +49,7 @@ cmd_handlers = (
       'drop-node', 'takeover'), londiste.LondisteSetup),
     (('add-table', 'remove-table', 'add-seq', 'remove-seq', 'tables', 'seqs',
       'missing', 'resync', 'check', 'fkeys', 'execute'), londiste.LondisteSetup),
+    (('show-handlers',), londiste.LondisteSetup),
     (('worker', 'replay'), londiste.Replicator),
     (('compare',), londiste.Comparator),
     (('repair',), londiste.Repairer),
index 9e52db5f1fecca5789e938ddd74d132f25ae540d..aff0e4cedbf140f10bc584f05f4b89a2ef084bab 100644 (file)
@@ -146,12 +146,15 @@ _handler_map = {
     'londiste': TableHandler,
 }
 
+_handler_list = _handler_map.keys()
+
 def register_handler_module(modname):
     """Import and module and register handlers."""
     __import__(modname)
     m = sys.modules[modname]
     for h in m.__londiste_handlers__:
         _handler_map[h.handler_name] = h
+        _handler_list.append(h.handler_name)
 
 def _parse_arglist(arglist):
     args = {}
@@ -203,3 +206,24 @@ def load_handler_modules(cf):
     for m in lst:
         register_handler_module(m)
 
+def show(mods):
+    if not mods:
+        if 0:
+            names = _handler_map.keys()
+            names.sort()
+        else:
+            names = _handler_list
+        for n in names:
+            kls = _handler_map[n]
+            desc = kls.__doc__ or ''
+            if desc:
+                desc = desc.split('\n', 1)[0]
+            print("%s - %s" % (n, desc))
+    else:
+        for n in mods:
+            kls = _handler_map[n]
+            desc = kls.__doc__ or ''
+            if desc:
+                desc = desc.rstrip()
+            print("%s - %s" % (n, desc))
+
index 6ec8ea602acfa360317784305d44751bb4b1b6d9..b59fd56f2536d1a7a01dfeef8ab838ea61f5c170 100644 (file)
@@ -368,6 +368,10 @@ class LondisteSetup(CascadeAdmin):
         """TODO: show removed triggers."""
         pass
 
+    def cmd_show_handlers(self, *args):
+        """Show help about handlers."""
+        londiste.handler.show(args)
+
     def cmd_execute(self, *files):
         db = self.get_database('db')
         curs = db.cursor()