cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/2] git commit: cloudmonkey: Fix cloudmonkey command line arg cleaning
Date Tue, 04 Nov 2014 13:02:05 GMT
cloudmonkey: Fix cloudmonkey command line arg cleaning

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/commit/24faf56d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/24faf56d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/24faf56d

Branch: refs/heads/master
Commit: 24faf56d5ab41cef1e9f7fc294f7cf1ab5e3a742
Parents: 75f617c
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Tue Nov 4 18:31:43 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Nov 4 18:31:43 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/24faf56d/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 32f0d79..e3790d3 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -759,9 +759,21 @@ def main():
 
     if len(args.commands) > 0:
         shell.set_attr("color", "false")
-        shell.onecmd(" ".join(map(lambda x: x.replace("\\ ", " ")
-                                             .replace(" ", "\\ "),
-                                  args.commands)))
+        commands = []
+        for command in args.commands:
+            split_command = command.split("=")
+            if len(split_command) > 1:
+                key = split_command[0]
+                value = split_command[1]
+                if " " not in value or \
+                   (value.startswith("\"") and value.endswith("\"")) or \
+                   (value.startswith("\'") and value.endswith("\'")):
+                    commands.append(command)
+                else:
+                    commands.append("%s=\"%s\"" % (key, value))
+            else:
+                commands.append(command)
+        shell.onecmd(" ".join(commands))
         if shell.error_on_last_command:
             sys.exit(1)
     else:


Mime
View raw message