Send Linux-ha-cvs mailing list submissions to linux-ha-cvs@lists.linux-ha.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Linux-ha-cvs digest..." Today's Topics: 1. Linux-HA CVS: crm by andrew from (linux-ha-cvs@lists.linux-ha.org) 2. Linux-HA CVS: linux-ha by lars from (linux-ha-cvs@lists.linux-ha.org) 3. Linux-HA CVS: crm by andrew from (linux-ha-cvs@lists.linux-ha.org) ---------------------------------------------------------------------- Message: 1 Date: Mon, 14 Aug 2006 07:07:46 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : andrew Host : Project : linux-ha Module : crm Dir : linux-ha/crm/admin Modified Files: cluster.py Log Message: Fix automatic help =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/crm/admin/cluster.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- cluster.py 14 Aug 2006 08:37:54 -0000 1.1 +++ cluster.py 14 Aug 2006 13:07:46 -0000 1.2 @@ -1,6 +1,6 @@ #!/bin/env python # -# $Id: cluster.py,v 1.1 2006/08/14 08:37:54 andrew Exp $ +# $Id: cluster.py,v 1.2 2006/08/14 13:07:46 andrew Exp $ # # pingd OCF Resource Agent # Records (in the CIB) the current number of ping nodes a @@ -88,22 +88,25 @@ ] def help_(text): + utl.log_dev("Looking up help text for: %s" % text) if text == "short": utl.log_info("cluster.py [global options] [topic [topic...]] [command]") return if text: - choice = findpossible(text) + choice = findpossible(text, None, False) for key in choice.keys(): alias, e = choice[key] + utl.log_dev("Help text for: %s" % alias[0]) if e: sub_cmd="" if len(e) > 4: utl.log_info("\n"+e[4]+"\n") - possible = findpossible("", alias[0]).keys() - possible.remove("up") - possible.remove("help") - possible.remove("exit") - if possible: + possible = findpossible("", alias[0]).keys() + utl.log_dev("Possible sub-commands: "+repr(possible)) + possible.remove("up") + possible.remove("help") + possible.remove("exit") + if possible: sub_cmd=' ('+'|'.join(possible)+')' if e[3]: utl.log_info("Usage: %s %s%s" % (alias[0], e[3], sub_cmd)) @@ -116,7 +119,7 @@ # Stolen from Mercurial commands.py -def findpossible(cmd, topic=None): +def findpossible(cmd, topic=None, filter=True): """ Return cmd -> (aliases, command table entry) for each matching command. @@ -131,7 +134,7 @@ for e in table.keys(): t = table[e] #utl.log_debug("Looking for "+topic +" in "+repr(t[1])) - if t[1] and topic not in t[1]: + if filter and t[1] and topic not in t[1]: continue aliases = e.lstrip("^").split("|") found = None @@ -239,12 +242,10 @@ cmdoptions["topic"] = cmd if not cmd: - utl.log_err(repr(args)) - cmd = "_unknown_" - raise UnknownCommand(None, "") - else: - d = lambda: func(*cmd_args, **cmdoptions) - return d() + utl.log_dev(repr(args)) + return 0 + d = lambda: func(*cmd_args, **cmdoptions) + return d() except crm.HelpRequest, inst: help_(inst.args[0]) @@ -341,7 +342,7 @@ utl.log_err("%s\n" % inst.args[0]) except KeyboardInterrupt: - utl.exit_(0) + pass except EOFError: utl.exit_(0) ------------------------------ Message: 2 Date: Mon, 14 Aug 2006 07:13:33 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: linux-ha by lars from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : lars Host : Module : linux-ha Dir : linux-ha Modified Files: configure.in Log Message: Remove removed file. =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/configure.in,v retrieving revision 1.545 retrieving revision 1.546 diff -u -3 -r1.545 -r1.546 --- configure.in 14 Aug 2006 09:09:14 -0000 1.545 +++ configure.in 14 Aug 2006 13:13:33 -0000 1.546 @@ -10,7 +10,7 @@ AC_INIT(heartbeat.spec.in) AC_CONFIG_AUX_DIR(.) -AC_REVISION($Revision: 1.545 $) dnl cvs revision +AC_REVISION($Revision: 1.546 $) dnl cvs revision AC_CANONICAL_HOST @@ -2627,7 +2627,6 @@ cts/extracttests.py \ cts/OCFIPraTest.py \ cts/CIB.py \ - cts/OCFMSDummy \ cts/LSBDummy \ crm/Makefile \ crm/cib/Makefile \ ------------------------------ Message: 3 Date: Mon, 14 Aug 2006 09:54:06 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : andrew Host : Project : linux-ha Module : crm Dir : linux-ha/crm/admin Modified Files: cluster.py crm_commands.py Log Message: Various tweaks to the cmd completion and lookup code =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/crm/admin/cluster.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- cluster.py 14 Aug 2006 13:07:46 -0000 1.2 +++ cluster.py 14 Aug 2006 15:54:05 -0000 1.3 @@ -1,6 +1,6 @@ #!/bin/env python # -# $Id: cluster.py,v 1.2 2006/08/14 13:07:46 andrew Exp $ +# $Id: cluster.py,v 1.3 2006/08/14 15:54:05 andrew Exp $ # # pingd OCF Resource Agent # Records (in the CIB) the current number of ping nodes a @@ -53,11 +53,11 @@ "^help": ( crm.help, None, [('v', 'verbose', None, 'extra information')], "[-v]"), - "^up": (crm.up, None, [], None, "Move up a level in the heirarchy"), - "^crm": (crm.cd_, ["crm"], [], None), - "^nodes": (crm.cd_, ["crm"], [], None), + "^up": (crm.up, None, [], None, "Move up a level in the heirarchy"), + "^crm": (crm.cd_, ["crm"], [], None), + "^nodes": (crm.cd_, ["crm"], [], None), "^resources": (crm.cd_, ["crm"], [], None), - "^config": (crm.cd_, ["crm"], [], None), + "^config": (crm.cd_, ["crm"], [], None), "^list": ( crm.do_list, ["nodes", "resources"], [('t', 'topic', "", '')], None), @@ -96,22 +96,25 @@ choice = findpossible(text, None, False) for key in choice.keys(): alias, e = choice[key] - utl.log_dev("Help text for: %s" % alias[0]) + text = alias[0] + utl.log_dev("Help text for: %s" % text) if e: sub_cmd="" if len(e) > 4: utl.log_info("\n"+e[4]+"\n") - possible = findpossible("", alias[0]).keys() + possible = findpossible("", text).keys() utl.log_dev("Possible sub-commands: "+repr(possible)) possible.remove("up") possible.remove("help") possible.remove("exit") + if text in possible: + possible.remove(text) if possible: sub_cmd=' ('+'|'.join(possible)+')' if e[3]: - utl.log_info("Usage: %s %s%s" % (alias[0], e[3], sub_cmd)) + utl.log_info("Usage: %s %s%s" % (text, e[3], sub_cmd)) else: - utl.log_info("Usage: %s%s" % (alias[0], sub_cmd)) + utl.log_info("Usage: %s%s" % (text, sub_cmd)) if choice: return; utl.log_err("No help text available for: %s" % text) @@ -127,24 +130,32 @@ """ if not topic: topic = utl.crm_topic + utl.log_dev("Searching in default topic: %s" % topic) - #utl.log_debug("Looking for completions in %s" % topic) + utl.log_dev("Looking for completions of %s in %s" % (cmd, topic)) choice = {} debugchoice = {} + topicchoice = {} for e in table.keys(): t = table[e] - #utl.log_debug("Looking for "+topic +" in "+repr(t[1])) + #utl.log_dev("Processing: %s / %s" % (e, repr(t))) + aliases = e.lstrip("^").split("|") + found = None + if "^%s"%topic == e and t[0] == crm.cd_: + #utl.log_dev("Found: topic") + topicchoice[topic] = (aliases, table[e]) if filter and t[1] and topic not in t[1]: + #utl.log_dev("Skip: filter") continue - aliases = e.lstrip("^").split("|") - found = None - if cmd in aliases: - found = cmd - else: - for a in aliases: - if a.startswith(cmd): - found = a - break + elif cmd in aliases: + #utl.log_dev("Found: alias") + found = cmd + else: + for a in aliases: + if a.startswith(cmd): + #utl.log_dev("Found: alias prefix") + found = a + break if found is not None: if aliases[0].startswith("debug"): debugchoice[found] = (aliases, table[e]) @@ -154,6 +165,9 @@ if not choice and debugchoice: choice = debugchoice + if not choice and topicchoice: + choice = topicchoice + return choice def findcmd(cmd): @@ -161,6 +175,7 @@ choice = findpossible(cmd) if choice.has_key(cmd): + #utl.log_dev("Choice has: %s" % cmd) return choice[cmd] if len(choice) > 1: @@ -169,6 +184,7 @@ raise AmbiguousCommand(cmd, clist) if choice: + #utl.log_dev("Returning first: %s" % (repr(choice.values()[0]))) return choice.values()[0] raise UnknownCommand(cmd) @@ -192,8 +208,10 @@ if args: cmd, args = args[0], args[1:] + utl.log_dev("Initial Command: %s" % cmd) aliases, i = findcmd(cmd) cmd = aliases[0] + utl.log_dev("Found Command: %s" % cmd) defaults = [] if defaults: args = defaults.split() + args @@ -222,29 +240,24 @@ return (cmd, cmd and i[0] or None, args, options, cmdoptions) def main_loop(args): - global global_opts cmd = None - cmd_args = [] - cmdoptions = {} - if not args: return 0 try: - utl.log_dev("Loop Input: "+repr(args)) - cmd, func, new_args, ignore, new_cmdoptions = parse(args) - - cmd_args.extend(new_args) - utl.log_dev(repr(cmd_args)) - cmdoptions.update(new_cmdoptions) + cmd, func, cmd_args, ignore, cmd_options = parse(args) if func == crm.cd_: - cmdoptions["topic"] = cmd + cmd_options["topic"] = cmd + + utl.log_dev("Func Command: %s" % cmd) + utl.log_dev("Func Args: %s" % repr(cmd_args)) + utl.log_dev("Func Opts: %s" % repr(cmd_options)) if not cmd: utl.log_dev(repr(args)) return 0 - d = lambda: func(*cmd_args, **cmdoptions) + d = lambda: func(*cmd_args, **cmd_options) return d() except crm.HelpRequest, inst: =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/crm/admin/crm_commands.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- crm_commands.py 14 Aug 2006 08:37:54 -0000 1.1 +++ crm_commands.py 14 Aug 2006 15:54:05 -0000 1.2 @@ -1,5 +1,5 @@ # -# $Id: crm_commands.py,v 1.1 2006/08/14 08:37:54 andrew Exp $ +# $Id: crm_commands.py,v 1.2 2006/08/14 15:54:05 andrew Exp $ # # pingd OCF Resource Agent # Records (in the CIB) the current number of ping nodes a @@ -38,10 +38,10 @@ """Exception raised when a command changed the command-line.""" def up(*args, **cmdoptions): - l = len(topic_stack) + l = len(utl.topic_stack) if l > 1: - topic_stack.pop() - utl.set_topic(topic_stack[-1]) + utl.topic_stack.pop() + utl.set_topic(utl.topic_stack[-1]) else: utl.log_debug("Already at the top of the stack") @@ -55,7 +55,7 @@ return utl.global_opts[flag] def cd_(*args, **cmdoptions): - global crm_topic + utl.log_dev("args: %s\nopts: %s" % (repr(args), repr(cmdoptions))) if not cmdoptions["topic"]: utl.log_err("No topic specified") return 1 ------------------------------ _______________________________________________ Linux-ha-cvs mailing list Linux-ha-cvs@lists.linux-ha.org http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs End of Linux-ha-cvs Digest, Vol 33, Issue 27 ********************************************