From b9ea0f43c186d5fbc232b0ddd11c3e64898136ab Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 13 Jul 2011 17:16:27 -0400 Subject: 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 7dfe91698..b5247f8c3 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 -- cgit From 7ed74cb999483e589e186944cb9116f507dbe60d Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 13 Jul 2011 22:01:52 -0400 Subject: 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 b5247f8c3..a83fe70f8 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 -- cgit From ee143766a32486664d47aee11f792854cbedd4ff Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 14 Jul 2011 07:08:02 -0400 Subject: add self to authors --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 2e50cfbe0..a366cec87 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 -- cgit