add support to write to stdout rather than file if '-' is specified.

see bug 810157
This commit is contained in:
Scott Moser
2011-07-14 19:13:15 +00:00
committed by Tarmac
2 changed files with 11 additions and 4 deletions

View File

@@ -85,6 +85,7 @@ Ryan Lucio <rlucio@internap.com>
Salvatore Orlando <salvatore.orlando@eu.citrix.com>
Sandy Walsh <sandy.walsh@rackspace.com>
Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
Scott Moser <smoser@ubuntu.com>
Soren Hansen <soren.hansen@rackspace.com>
Thierry Carrez <thierry@openstack.org>
Todd Willey <todd@ansolabs.com>

View File

@@ -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 == "-":
sys.stdout.write(rc)
else:
with open(filename, 'w') as f:
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 == "-":
sys.stdout.write(zip_file)
else:
with open(filename, 'w') as f:
f.write(zip_file)
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
print ex
raise