You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/11/15 14:14:12 UTC
[1/3] git commit: cli: Split using only space
Updated Branches:
refs/heads/master fe460fac4 -> 08d16cf4d
cli: Split using only space
Patch fixes lexical parser for default argument on shell.
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7ae8c4ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7ae8c4ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7ae8c4ad
Branch: refs/heads/master
Commit: 7ae8c4ad7ec37c089e9cade0239faa7cde223896
Parents: fe460fa
Author: Rohit Yadav <bh...@apache.org>
Authored: Thu Nov 15 18:18:50 2012 +0530
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Nov 15 18:43:51 2012 +0530
----------------------------------------------------------------------
tools/cli/cloudmonkey/cloudmonkey.py | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ae8c4ad/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py
index 83bd8c1..4ba6dbf 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -223,7 +223,10 @@ class CloudStackShell(cmd.Cmd):
return api_mod
def default(self, args):
- args = shlex.split(args.strip())
+ lexp = shlex.shlex(args.strip())
+ lexp.whitespace = " "
+ lexp.whitespace_split = True
+ args = list(lexp)
api_name = args[0]
try:
@@ -417,6 +420,12 @@ def main():
for rule in grammar:
def add_grammar(rule):
def grammar_closure(self, args):
+ if '|' in args: #FIXME: Consider parsing issues
+ prog_name = sys.argv[0]
+ if '.py' in prog_name:
+ prog_name = "python " + prog_name
+ self.do_shell("%s %s %s" % (prog_name, rule, args))
+ return
if not rule in self.cache_verbs:
self.cache_verb_miss(rule)
try:
@@ -428,13 +437,7 @@ def main():
if '--help' in args:
self.print_shell(res[2])
return
- if '|' in args:
- prog_name = sys.argv[0]
- if '.py' in prog_name:
- prog_name = "python " + prog_name
- self.do_shell("%s %s %s" % (prog_name, rule, args))
- else:
- self.default(res[0] + " " + args_partition[2])
+ self.default(res[0] + " " + args_partition[2])
return grammar_closure
grammar_handler = add_grammar(rule)