From 2ef610dfde5706d1957b9251009620f59b3c38a0 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 13 Jul 2011 17:16:27 -0400 Subject: [PATCH 1/3] support '-' to indicate stdout in nova-manage project 'environment' and 'zip' This just adds support to do: nova-manage project zip test-project admin - > out.zip nova-manage project environment test-project admin - | grep NOVA_URL --- bin/nova-manage | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 7dfe9169..b5247f8c 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -414,8 +414,11 @@ class ProjectCommands(object): except (exception.UserNotFound, exception.ProjectNotFound) as ex: print ex raise - with open(filename, 'w') as f: - f.write(rc) + if filename == "-": + f = sys.stdout + else: + f = open(filename, 'w') + f.write(rc) def list(self, username=None): """Lists all projects @@ -465,8 +468,11 @@ class ProjectCommands(object): arguments: project_id user_id [filename='nova.zip]""" try: zip_file = self.manager.get_credentials(user_id, project_id) - with open(filename, 'w') as f: - f.write(zip_file) + if filename == "-": + f = sys.stdout + else: + f = open(filename, 'w') + f.write(zip_file) except (exception.UserNotFound, exception.ProjectNotFound) as ex: print ex raise From bafb23fb2e0c3bf28d13f07c842cc67b3aaf80aa Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 13 Jul 2011 22:01:52 -0400 Subject: [PATCH 2/3] use 'with' so that close is called on file handle --- bin/nova-manage | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index b5247f8c..a83fe70f 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -415,10 +415,10 @@ class ProjectCommands(object): print ex raise if filename == "-": - f = sys.stdout + sys.stdout.write(rc) else: - f = open(filename, 'w') - f.write(rc) + with open(filename, 'w') as f: + f.write(rc) def list(self, username=None): """Lists all projects @@ -469,10 +469,10 @@ class ProjectCommands(object): try: zip_file = self.manager.get_credentials(user_id, project_id) if filename == "-": - f = sys.stdout + sys.stdout.write(zip_file) else: - f = open(filename, 'w') - f.write(zip_file) + with open(filename, 'w') as f: + f.write(zip_file) except (exception.UserNotFound, exception.ProjectNotFound) as ex: print ex raise From ae5908c0594bfe1734ace2c0ad92a7109825e713 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 14 Jul 2011 07:08:02 -0400 Subject: [PATCH 3/3] add self to authors --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 2e50cfbe..a366cec8 100644 --- a/Authors +++ b/Authors @@ -85,6 +85,7 @@ Ryan Lucio Salvatore Orlando Sandy Walsh Sateesh Chodapuneedi +Scott Moser Soren Hansen Thierry Carrez Todd Willey