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 2016/01/19 15:27:35 UTC

[1/3] cloudstack-cloudmonkey git commit: cloudmonkey: manually print csv header

Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master 32b110a34 -> f7d04378c


cloudmonkey: manually print csv header

Python 2.6 and below don't have 'writeheader' method, so simply
print the header manually

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

Branch: refs/heads/master
Commit: b46321672690b784086123547c72ed1fafa0b49b
Parents: 32b110a
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Tue Jan 19 15:22:22 2016 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 19 15:22:22 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/b4632167/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index b057a2a..e7d3c53 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -280,7 +280,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
                 if isinstance(result[0], dict):
                     keys = result[0].keys()
                     writer = csv.DictWriter(sys.stdout, keys)
-                    writer.writeheader()
+                    print ','.join(keys)
                     for item in result:
                         for k in keys:
                             if k not in item:
@@ -290,8 +290,9 @@ class CloudMonkeyShell(cmd.Cmd, object):
                                     item[k] = item[k].encode('utf8')
                         writer.writerow(item)
             elif isinstance(result, dict):
-                writer = csv.DictWriter(sys.stdout, result.keys())
-                writer.writeheader()
+                keys = result.keys()
+                writer = csv.DictWriter(sys.stdout, keys)
+                print ','.join(keys)
                 writer.writerow(result)
 
         def print_result_tabular(result):


[3/3] cloudstack-cloudmonkey git commit: CHANGES: update changes file

Posted by bh...@apache.org.
CHANGES: update changes file

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

Branch: refs/heads/master
Commit: f7d04378c39904381638a31abb8d2c5eefbe38ff
Parents: 5c7f906
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Tue Jan 19 15:27:23 2016 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 19 15:27:23 2016 +0100

----------------------------------------------------------------------
 CHANGES.md | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/f7d04378/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 113e8cc..013d837 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,6 +5,8 @@ Version 5.3.3
 =============
 This release includes
 - Support for shell history
+- Sort autocompletion suggestion based on names
+- Improve CSV output and error handling
 
 Version 5.3.2
 =============


[2/3] cloudstack-cloudmonkey git commit: cloudmonkey: print csv rows based on what's available

Posted by bh...@apache.org.
cloudmonkey: print csv rows based on what's available

This fails if the row item has any additional key than the first row with error:
Error on parsing and printing dict contains fields not in fieldnames

The fix is to start with an empty dictionary fill it based on known keys and
then ask csv to print that row

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

Branch: refs/heads/master
Commit: 5c7f906fae1656e1dc072097ee9061b0f3bbefd4
Parents: b463216
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Tue Jan 19 15:24:01 2016 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 19 15:25:35 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/5c7f906f/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index e7d3c53..fc43167 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -282,13 +282,16 @@ class CloudMonkeyShell(cmd.Cmd, object):
                     writer = csv.DictWriter(sys.stdout, keys)
                     print ','.join(keys)
                     for item in result:
+                        row = {}
                         for k in keys:
                             if k not in item:
-                                item[k] = None
+                                row[k] = None
                             else:
                                 if type(item[k]) is unicode:
-                                    item[k] = item[k].encode('utf8')
-                        writer.writerow(item)
+                                    row[k] = item[k].encode('utf8')
+                                else:
+                                    row[k] = item[k]
+                        writer.writerow(row)
             elif isinstance(result, dict):
                 keys = result.keys()
                 writer = csv.DictWriter(sys.stdout, keys)