Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master eae19737f -> beb369c59


cloudmonkey: fix set command issue, close stdout/err when exiting cloudmonkey

Signed-off-by: Rohit Yadav <rohit.ya...@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/beb369c5
Tree: 
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/beb369c5
Diff: 
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/beb369c5

Branch: refs/heads/master
Commit: beb369c5913f3c19e2b8132892c1bcd116394ceb
Parents: eae1973
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Mon Nov 3 22:14:23 2014 +0530
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Mon Nov 3 22:14:23 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py | 21 +++++++++++++++++----
 cloudmonkey/requester.py   |  3 ++-
 setup.py                   |  6 ++++++
 3 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/beb369c5/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 0f46c72..f8d2e47 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -193,6 +193,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
         else:
             if output.startswith("Error"):
                 sys.stderr.write(output + "\n")
+                sys.stderr.flush()
             else:
                 print output
 
@@ -435,7 +436,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
                 param = param[:idx]
                 if param == "filter":
                     response_params = self.apicache[verb][subject]["response"]
-                    used = filter(lambda x: x.strip() != "", 
value.split(",")[:-1])
+                    used = filter(lambda x: x.strip() != "",
+                                  value.split(",")[:-1])
                     unused = map(lambda x: x['name'] + ",", filter(lambda x:
                                  "name" in x and x["name"] not in used,
                                  response_params))
@@ -450,7 +452,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
                     if normal_readline:
                         return filter(lambda x: x.startswith(last_value),
                                       map(lambda x: x, unused))
-                    else: # OSX fix
+                    else:  # OSX fix
                         return filter(lambda x: x.startswith(value),
                                       map(lambda x: suffix + x, unused))
                 elif len(value) < 36 and idx != -1:
@@ -563,7 +565,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
         key, value = (args[0].strip(), args[2].strip())
         if not key:
             return
-        if not value:
+        allowed_blank_keys = ["username", "password", "apikey", "secretkey"]
+        if key not in allowed_blank_keys and not value:
             print "Blank value of %s is not allowed" % key
             return
 
@@ -599,7 +602,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
         elif option == "display":
             return [s for s in ["default", "table", "json"]
                     if s.startswith(value)]
-        elif option == "asyncblock" or option == "color":
+        elif option in ["asyncblock", "color", "paramcompletion"]:
             return [s for s in ["true", "false"] if s.startswith(value)]
 
         return []
@@ -762,5 +765,15 @@ def main():
     else:
         shell.cmdloop()
 
+    try:
+        sys.stdout.close()
+    except:
+        pass
+    try:
+        sys.stderr.close()
+    except:
+        pass
+
+
 if __name__ == "__main__":
     main()

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/beb369c5/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py
index ad243a3..363f1cd 100644
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@ -44,6 +44,7 @@ def logger_debug(logger, message):
 def writeError(msg):
     sys.stderr.write(msg)
     sys.stderr.write("\n")
+    sys.stderr.flush()
 
 
 def login(url, username, password):
@@ -291,7 +292,7 @@ def monkeyrequest(command, args, isasync, asyncblock, 
logger, url,
                 print "\r" + " " * progress
                 return response, error
             elif jobstatus == 0:
-                pass # Job in progress
+                pass  # Job in progress
             else:
                 logger_debug(logger, "We should not arrive here!")
                 sys.stdout.flush()

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/beb369c5/setup.py
----------------------------------------------------------------------
diff --git a/setup.py b/setup.py
index 854af9c..52a053d 100644
--- a/setup.py
+++ b/setup.py
@@ -44,6 +44,12 @@ except ImportError:
     else:
         requires.append('readline')
 
+# Upgrade notes for 5.3.0
+print "If you're upgrading, run the following to enable parameter completion:"
+print "  cloudmonkey sync"
+print "  cloudmonkey set paramcompletion true"
+print "Parameter completion may fail, if the above is not run!"
+
 setup(
     name = 'cloudmonkey',
     version = __version__,

Reply via email to