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 2015/06/19 14:56:54 UTC
cloudstack-cloudmonkey git commit: cloudmonkey: fix csv output to
correctly output UTF8 strings
Repository: cloudstack-cloudmonkey
Updated Branches:
refs/heads/master 3d9dfaedf -> fda310293
cloudmonkey: fix csv output to correctly output UTF8 strings
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/fda31029
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/fda31029
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/fda31029
Branch: refs/heads/master
Commit: fda310293690ca0cb0b0882e3fe8a042b9305c92
Parents: 3d9dfae
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Jun 19 15:56:20 2015 +0300
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Jun 19 15:56:20 2015 +0300
----------------------------------------------------------------------
cloudmonkey/cloudmonkey.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/fda31029/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 44baf58..51cf2c2 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -270,9 +270,16 @@ class CloudMonkeyShell(cmd.Cmd, object):
if isinstance(result, list) and len(result) > 0:
if isinstance(result[0], dict):
- writer = csv.DictWriter(sys.stdout, result[0].keys())
+ keys = result[0].keys()
+ writer = csv.DictWriter(sys.stdout, keys)
writer.writeheader()
for item in result:
+ for k in keys:
+ if k not in item:
+ item[k] = None
+ else:
+ if type(item[k]) is unicode:
+ item[k] = item[k].encode('utf8')
writer.writerow(item)
elif isinstance(result, dict):
writer = csv.DictWriter(sys.stdout, result.keys())