From 966beafd978e726d5ca2fa574c7d71e616a7e7a4 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Tue, 8 Jul 2014 05:32:32 -0600 Subject: [PATCH] Minor fixes to examples * Fix typo in authenticate * Add comments to head command * Fix name of head method * Use find_resource_cls for lists Change-Id: If4bb485088460151916e1d2b9b5fe80ad150dcff --- examples/authenticate.py | 2 +- examples/head.py | 12 ++++++++++-- examples/list.py | 12 +----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/examples/authenticate.py b/examples/authenticate.py index 981c62c6b..de0e150a8 100644 --- a/examples/authenticate.py +++ b/examples/authenticate.py @@ -14,7 +14,7 @@ Authentication example To authenticate you must have the environment variables set or use the -command line options. This is a good example to start wtih because once +command line options. This is a good example to start with because once you know you can authenticate, you can perform other operations that require authentication. Refer to the example common.py for the environment variables or command line options to use. diff --git a/examples/head.py b/examples/head.py index bc7ba9f3f..87e80de34 100644 --- a/examples/head.py +++ b/examples/head.py @@ -10,13 +10,21 @@ # License for the specific language governing permissions and limitations # under the License. +""" +Example Head Command + +For example: + python -m examples.head openstack/image/v1/image.py \ + --data 9d7d22d0-7d43-481f-a7eb-d93ea2791409 +""" + import sys from examples import common from examples import session -def run_get(opts): +def run_head(opts): sess = session.make_session(opts) cls = common.find_resource_cls(opts) data = common.get_data_option(opts) @@ -28,4 +36,4 @@ def run_get(opts): if __name__ == "__main__": opts = common.setup() - sys.exit(common.main(opts, run_get)) + sys.exit(common.main(opts, run_head)) diff --git a/examples/list.py b/examples/list.py index ed94c58e6..0246b6484 100644 --- a/examples/list.py +++ b/examples/list.py @@ -16,19 +16,9 @@ from examples import common from examples import session -def make_resource(opts): - argument = opts.argument - args = argument.rpartition('.') - from_str = args[0] - class_str = args[2] - __import__(from_str) - mod = sys.modules[from_str] - return getattr(mod, class_str) - - def run_list(opts): sess = session.make_session(opts) - cls = make_resource(opts) + cls = common.find_resource_cls(opts) for obj in cls.list(sess): print(str(obj)) return