You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/04/10 00:49:04 UTC

[24/26] git commit: updated refs/heads/affinity_groups to 90172c3

cli: Remove tabularize, fix display types, make code pep8 compliant

- Remove tabularize field
- Now display types are: default, json and table
- Make requester pep8 compliant
- Remove unnecessary comments, if we want them we should put them on each method

Signed-off-by: Rohit Yadav <bh...@apache.org>


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

Branch: refs/heads/affinity_groups
Commit: ff74cbbeeac726a2f988f0a2fcda78e74f9af64d
Parents: 9fbae85
Author: Rohit Yadav <bh...@apache.org>
Authored: Fri Apr 5 23:06:44 2013 +0530
Committer: Rohit Yadav <bh...@apache.org>
Committed: Fri Apr 5 23:06:44 2013 +0530

----------------------------------------------------------------------
 tools/cli/cloudmonkey/cloudmonkey.py |   17 ++++-------------
 tools/cli/cloudmonkey/config.py      |   15 ++-------------
 tools/cli/cloudmonkey/requester.py   |   15 ++++++++-------
 3 files changed, 14 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff74cbbe/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py
index 14d7d94..13f54ad 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -163,10 +163,6 @@ class CloudMonkeyShell(cmd.Cmd, object):
                 self.monkeyprint(printer)
             return PrettyTable(toprow)
 
-        # method: print_result_json( result, result_filter )
-        # parameters: result - raw results from the API call
-        #             result_filter - filterset
-        # description: prints result as a json object
         def print_result_json(result, result_filter=None):
             tfilter = {}  # temp var to hold a dict of the filters
             tresult = copy.deepcopy(result)  # dupe the result to filter
@@ -222,9 +218,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
                 self.monkeyprint(printer)
 
         def print_result_as_dict(result, result_filter=None):
-
-            # tabularize overrides self.display
-            if self.display == "json" and not self.tabularize == "true":
+            if self.display == "json":
                 print_result_json(result, result_filter)
                 return
 
@@ -239,9 +233,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
 
         def print_result_as_list(result, result_filter=None):
             for node in result:
-                # Tabular print if it's a list of dict and tabularize is true
-                if isinstance(node, dict) and (self.display == 'tabularize' or
-                                               self.tabularize == 'true'):
+                if isinstance(node, dict) and self.display == 'table':
                     print_result_tabular(result, result_filter)
                     break
                 self.print_result(node)
@@ -364,9 +356,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
                     autocompletions = uuids
                     search_string = value
 
-        if subject != "" and (self.display == "tabularize" or
-                              self.display == "json" or
-                              self.tabularize == "true"):
+        if subject != "" and (self.display == "table" or
+                              self.display == "json"):
             autocompletions.append("filter=")
         return [s for s in autocompletions if s.startswith(search_string)]
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff74cbbe/tools/cli/cloudmonkey/config.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/config.py b/tools/cli/cloudmonkey/config.py
index b21ae4c..aaf97eb 100644
--- a/tools/cli/cloudmonkey/config.py
+++ b/tools/cli/cloudmonkey/config.py
@@ -56,8 +56,7 @@ config_fields['core']['log_file'] = expanduser(config_dir + '/log')
 # ui
 config_fields['ui']['color'] = 'true'
 config_fields['ui']['prompt'] = '> '
-config_fields['ui']['tabularize'] = 'false' # deprecate - REMOVE
-config_fields['ui']['display'] = 'default' # default display mechanism
+config_fields['ui']['display'] = 'default'
 
 # server
 config_fields['server']['host'] = 'localhost'
@@ -112,19 +111,9 @@ def read_config(get_attr, set_attr, config_file):
     for section in config_fields.keys():
         for key in config_fields[section].keys():
             try:
-                if( key == "tabularize" ): # this key is deprecated
-                    print "\ntabularize config parameter is deprecated:",
-                    print "please switch to display =",
-                    print "[default,json,tabularize]\n"
                 set_attr(key, config.get(section, key))
             except Exception:
-                if( key == "tabularize" ): # this key is deprecated
-                    set_attr( key, "false" ) # set default
-                elif( key == "display" ): # this key is deprecated
-                    config = write_config(get_attr, config_file, True)
-                    set_attr( key, "default" ) # set default
-                else:
-                    missing_keys.append(key)
+                missing_keys.append(key)
 
     if len(missing_keys) > 0:
         print "Please fix `%s` in %s" % (', '.join(missing_keys), config_file)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff74cbbe/tools/cli/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/requester.py b/tools/cli/cloudmonkey/requester.py
index e6ea6a1..88967fe 100644
--- a/tools/cli/cloudmonkey/requester.py
+++ b/tools/cli/cloudmonkey/requester.py
@@ -138,9 +138,9 @@ def monkeyrequest(command, args, isasync, asyncblock, logger, host, port,
                 time.sleep(pollperiod)
             else:
                 response, error = monkeyrequest(command, request, isasync,
-                                            asyncblock, logger,
-                                            host, port,  apikey, secretkey,
-                                            timeout, protocol, path)
+                                                asyncblock, logger,
+                                                host, port,  apikey, secretkey,
+                                                timeout, protocol, path)
 
             responsekeys = filter(lambda x: 'response' in x, response.keys())
 
@@ -161,15 +161,16 @@ def monkeyrequest(command, args, isasync, asyncblock, logger, host, port,
                 sys.stdout.flush()
 
             if jobresultcode != 0:
-                error = "Error: resultcode %d for jobid %s" % (jobresultcode, jobid)
+                error = "Error: resultcode %d for jobid %s" % (jobresultcode,
+                                                               jobid)
                 logger_debug(logger, "%s" % (error))
                 return response, error
             else:
                 # if we get a valid respons resultcode give back results
                 response, error = monkeyrequest(command, request, isasync,
-                            asyncblock, logger,
-                            host, port,  apikey, secretkey,
-                            timeout, protocol, path)
+                                                asyncblock, logger,
+                                                host, port,  apikey, secretkey,
+                                                timeout, protocol, path)
                 logger_debug(logger, "Ok: %s" % (jobid))
                 return response, error