From f0445a1b443182cf77e27038cc5f90c424e00c62 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 13 Jul 2012 22:03:22 +0000 Subject: Rewrite link parsing for finding v2 schemas What we called 'links' are no longer returned in a container of objects, they are top-level entity attribtues. This fixes the parsing of the entities to look in the correct place when trying to locate a specific schema. Add a helper for printing to stderr and exiting with a non-zero exit code. Map 'name' to 'Attribute' when explaining a schema. Related to bp glance-client-v2 Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a05 --- glanceclient/common/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'glanceclient/common/utils.py') diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 8bbb7ac..07e77a1 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -14,6 +14,7 @@ # under the License. import os +import sys import uuid import prettytable @@ -47,7 +48,7 @@ def print_list(objs, fields, formatters={}): row.append(formatters[field](o)) else: field_name = field.lower().replace(' ', '_') - data = getattr(o, field_name, '') + data = getattr(o, field_name, None) or '' row.append(data) pt.add_row(row) @@ -123,3 +124,9 @@ def import_versioned_module(version, submodule=None): if submodule: module = '.'.join((module, submodule)) return importutils.import_module(module) + + +def exit(msg=''): + if msg: + print >> sys.stderr, msg + sys.exit(1) -- cgit v1.2.1