cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/3] cloudstack-cloudmonkey git commit: cloudmonkey: manually print csv header
Date Tue, 19 Jan 2016 14:27:35 GMT
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 <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/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 <rohit.yadav@shapeblue.com>
Authored: Tue Jan 19 15:22:22 2016 +0100
Committer: Rohit Yadav <rohit.yadav@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):


Mime
View raw message